mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
Apply clippy lints
This commit is contained in:
+7
-7
@@ -61,12 +61,12 @@ impl DisplayData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_children_from_node(&self, node: Node) -> impl Iterator<Item = Box<Node>> {
|
fn get_children_from_node(&self, node: Node) -> impl Iterator<Item = Node> {
|
||||||
if self.is_reversed {
|
if self.is_reversed {
|
||||||
let n: Vec<Box<Node>> = node.children.into_iter().rev().map(|a| a).collect();
|
let n: Vec<Node> = node.children.into_iter().rev().map(|a| a).collect();
|
||||||
return n.into_iter();
|
n.into_iter()
|
||||||
} else {
|
} else {
|
||||||
return node.children.into_iter();
|
node.children.into_iter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ pub fn draw_it(permissions: bool, use_full_path: bool, is_reversed: bool, root_n
|
|||||||
|
|
||||||
for c in display_data.get_children_from_node(root_node) {
|
for c in display_data.get_children_from_node(root_node) {
|
||||||
let first_tree_chars = display_data.get_first_chars();
|
let first_tree_chars = display_data.get_first_chars();
|
||||||
display_node(*c, true, first_tree_chars, &display_data)
|
display_node(c, true, first_tree_chars, &display_data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,10 +101,10 @@ fn display_node(node: Node, is_biggest: bool, indent: &str, display_data: &Displ
|
|||||||
|
|
||||||
for c in display_data.get_children_from_node(node) {
|
for c in display_data.get_children_from_node(node) {
|
||||||
num_siblings -= 1;
|
num_siblings -= 1;
|
||||||
let chars = display_data.get_tree_chars(num_siblings, max_sibling, c.children.len() > 0);
|
let chars = display_data.get_tree_chars(num_siblings, max_sibling, !c.children.is_empty());
|
||||||
let is_biggest = display_data.is_biggest(num_siblings, max_sibling);
|
let is_biggest = display_data.is_biggest(num_siblings, max_sibling);
|
||||||
let full_indent = new_indent.clone() + chars;
|
let full_indent = new_indent.clone() + chars;
|
||||||
display_node(*c, is_biggest, &*full_indent, display_data)
|
display_node(c, is_biggest, &*full_indent, display_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if display_data.is_reversed {
|
if display_data.is_reversed {
|
||||||
|
|||||||
+2
-3
@@ -142,10 +142,9 @@ fn recursively_build_tree(parent_node: &mut Node, new_node: Node, depth: Option<
|
|||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|c| new_node.name.starts_with(&c.name))
|
.find(|c| new_node.name.starts_with(&c.name))
|
||||||
{
|
{
|
||||||
recursively_build_tree(&mut *c, new_node, new_depth);
|
recursively_build_tree(c, new_node, new_depth);
|
||||||
} else {
|
} else {
|
||||||
let temp = Box::<Node>::new(new_node);
|
parent_node.children.push(new_node);
|
||||||
parent_node.children.push(temp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -1,7 +1,6 @@
|
|||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
use jwalk::WalkDir;
|
use jwalk::WalkDir;
|
||||||
|
|
||||||
@@ -12,7 +11,7 @@ use self::platform::*;
|
|||||||
pub struct Node {
|
pub struct Node {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub size: u64,
|
pub size: u64,
|
||||||
pub children: Vec<Box<Node>>,
|
pub children: Vec<Node>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn simplify_dir_names(filenames: Vec<&str>) -> HashSet<String> {
|
pub fn simplify_dir_names(filenames: Vec<&str>) -> HashSet<String> {
|
||||||
@@ -107,7 +106,7 @@ fn examine_dir(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// This path and all its parent paths have their counter incremented
|
// This path and all its parent paths have their counter incremented
|
||||||
for path_name in PathBuf::from(e.path()).ancestors() {
|
for path_name in e.path().ancestors() {
|
||||||
let path_name = path_name.to_string_lossy();
|
let path_name = path_name.to_string_lossy();
|
||||||
let s = data.entry(path_name.to_string()).or_insert(0);
|
let s = data.entry(path_name.to_string()).or_insert(0);
|
||||||
*s += size;
|
*s += size;
|
||||||
|
|||||||
Reference in New Issue
Block a user