mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
clippy: Fix clippy lints
New rustup adds more lints
This commit is contained in:
+1
-1
@@ -102,7 +102,7 @@ fn walk(dir: PathBuf, permissions_flag: &AtomicBool, walk_data: &WalkData) -> Op
|
||||
|
||||
// return walk(entry.path(), permissions_flag, ignore_directories, allowed_filesystems, use_apparent_size, by_filecount, ignore_hidden);
|
||||
|
||||
if !ignore_file(&entry, walk_data) {
|
||||
if !ignore_file(entry, walk_data) {
|
||||
if let Ok(data) = entry.file_type() {
|
||||
if data.is_dir() && !data.is_symlink() {
|
||||
return walk(entry.path(), permissions_flag, walk_data);
|
||||
|
||||
+4
-4
@@ -265,9 +265,9 @@ fn pad_or_trim_filename(node: &DisplayNode, indent: &str, display_data: &Display
|
||||
|
||||
// Add spaces after the filename so we can draw the % used bar chart.
|
||||
let name_and_padding = name
|
||||
+ &(repeat(" ")
|
||||
.take(display_data.longest_string_length - width)
|
||||
.collect::<String>());
|
||||
+ " "
|
||||
.repeat(display_data.longest_string_length - width)
|
||||
.as_str();
|
||||
|
||||
maybe_trim_filename(name_and_padding, display_data)
|
||||
}
|
||||
@@ -320,7 +320,7 @@ fn get_pretty_size(node: &DisplayNode, is_biggest: bool, display_data: &DisplayD
|
||||
let size_as_str = node.size.separate_with_commas();
|
||||
let spaces_to_add =
|
||||
display_data.num_chars_needed_on_left_most - size_as_str.chars().count();
|
||||
size_as_str + &*repeat(' ').take(spaces_to_add).collect::<String>()
|
||||
size_as_str + " ".repeat(spaces_to_add).as_str()
|
||||
} else {
|
||||
format!("{:>5}", human_readable_number(node.size))
|
||||
};
|
||||
|
||||
+6
-5
@@ -36,11 +36,12 @@ impl DisplayNode {
|
||||
}
|
||||
|
||||
pub fn get_children_from_node(&self, is_reversed: bool) -> impl Iterator<Item = DisplayNode> {
|
||||
if is_reversed {
|
||||
let children: Vec<DisplayNode> = self.children.clone().into_iter().rev().collect();
|
||||
children.into_iter()
|
||||
// we box to avoid the clippy lint warning
|
||||
let out: Box<dyn Iterator<Item = DisplayNode>> = if is_reversed {
|
||||
Box::new(self.children.clone().into_iter().rev())
|
||||
} else {
|
||||
self.children.clone().into_iter()
|
||||
}
|
||||
Box::new(self.children.clone().into_iter())
|
||||
};
|
||||
out
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -120,9 +120,9 @@ pub fn get_metadata(d: &Path, _use_apparent_size: bool) -> Option<(u64, Option<(
|
||||
{
|
||||
Some((md.len(), None))
|
||||
} else {
|
||||
get_metadata_expensive(&d)
|
||||
get_metadata_expensive(d)
|
||||
}
|
||||
}
|
||||
_ => get_metadata_expensive(&d),
|
||||
_ => get_metadata_expensive(d),
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ pub fn get_filesystem_devices<'a, P: IntoIterator<Item = &'a PathBuf>>(paths: P)
|
||||
paths
|
||||
.into_iter()
|
||||
.filter_map(|p| {
|
||||
let meta = get_metadata(&p, false);
|
||||
let meta = get_metadata(p, false);
|
||||
|
||||
if let Some((_size, Some((_id, dev)))) = meta {
|
||||
Some(dev)
|
||||
|
||||
Reference in New Issue
Block a user