clippy clean
This commit is contained in:
parent
1277870097
commit
5fedd82dda
|
@ -1,6 +1,6 @@
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use egui::Color32;
|
use egui::Color32;
|
||||||
use std::{cmp::min, fs, io, path::Path, path::PathBuf, ffi::OsStr};
|
use std::{cmp::min, ffi::OsStr, fs, io, path::Path, path::PathBuf};
|
||||||
|
|
||||||
use crate::tools;
|
use crate::tools;
|
||||||
use crate::Calcifer;
|
use crate::Calcifer;
|
||||||
|
@ -143,11 +143,9 @@ impl Calcifer {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
egui::CollapsingHeader::new(name).show(ui, |ui| {
|
egui::CollapsingHeader::new(name).show(ui, |ui| match fs::read_dir(path) {
|
||||||
match fs::read_dir(path) {
|
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
ui.label(format!("Error reading directory: {}", err));
|
ui.label(format!("Error reading directory: {}", err));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Ok(entries) => {
|
Ok(entries) => {
|
||||||
let mut paths: Vec<Result<fs::DirEntry, io::Error>> = entries
|
let mut paths: Vec<Result<fs::DirEntry, io::Error>> = entries
|
||||||
|
@ -155,9 +153,7 @@ impl Calcifer {
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
paths.sort_by(|a, b| match (a, b) {
|
paths.sort_by(|a, b| match (a, b) {
|
||||||
(Ok(entry_a), Ok(entry_b)) => {
|
(Ok(entry_a), Ok(entry_b)) => tools::sort_directories_first(entry_a, entry_b),
|
||||||
tools::sort_directories_first(&entry_a, &entry_b)
|
|
||||||
}
|
|
||||||
(Err(_), Ok(_)) => std::cmp::Ordering::Greater,
|
(Err(_), Ok(_)) => std::cmp::Ordering::Greater,
|
||||||
(Ok(_), Err(_)) => std::cmp::Ordering::Less,
|
(Ok(_), Err(_)) => std::cmp::Ordering::Less,
|
||||||
(Err(_), Err(_)) => std::cmp::Ordering::Equal,
|
(Err(_), Err(_)) => std::cmp::Ordering::Equal,
|
||||||
|
@ -174,7 +170,6 @@ impl Calcifer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use eframe::egui::text_edit::CCursorRange;
|
use eframe::egui::text_edit::CCursorRange;
|
||||||
use std::{fs::read_to_string, path::PathBuf};
|
use std::{fs::read_to_string, path::Path, path::PathBuf};
|
||||||
|
|
||||||
use crate::MAX_TABS;
|
use crate::MAX_TABS;
|
||||||
|
|
||||||
|
@ -85,16 +85,16 @@ impl Tab {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_file_contents(path: &PathBuf) -> String {
|
fn read_file_contents(path: &Path) -> String {
|
||||||
read_to_string(path.clone())
|
read_to_string(path.to_path_buf())
|
||||||
.map_err(|err| format!("// Error reading file: {}", err))
|
.map_err(|err| format!("// Error reading file: {}", err))
|
||||||
.unwrap_or_else(|err_msg| err_msg)
|
.unwrap_or_else(|err_msg| err_msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn format_file_path(path: &PathBuf, contents: &str) -> PathBuf {
|
fn format_file_path(path: &Path, contents: &str) -> PathBuf {
|
||||||
if contents.contains("Error reading file") {
|
if contents.contains("Error reading file") {
|
||||||
"untitled".into()
|
"untitled".into()
|
||||||
} else {
|
} else {
|
||||||
path.clone()
|
path.to_path_buf()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue