diff --git a/src/display.rs b/src/display.rs index 343ab81..f7d6a49 100644 --- a/src/display.rs +++ b/src/display.rs @@ -61,12 +61,12 @@ impl DisplayData { } } - fn get_children_from_node(&self, node: Node) -> impl Iterator> { + fn get_children_from_node(&self, node: Node) -> impl Iterator { if self.is_reversed { - let n: Vec> = node.children.into_iter().rev().map(|a| a).collect(); - return n.into_iter(); + let n: Vec = node.children.into_iter().rev().map(|a| a).collect(); + n.into_iter() } 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) { 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) { 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 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 { diff --git a/src/main.rs b/src/main.rs index 4a596fe..fb28148 100644 --- a/src/main.rs +++ b/src/main.rs @@ -142,10 +142,9 @@ fn recursively_build_tree(parent_node: &mut Node, new_node: Node, depth: Option< .iter_mut() .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 { - let temp = Box::::new(new_node); - parent_node.children.push(temp); + parent_node.children.push(new_node); } } diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 5b63be8..5e649d2 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,7 +1,6 @@ use std::cmp::Ordering; use std::collections::HashMap; use std::collections::HashSet; -use std::path::PathBuf; use jwalk::WalkDir; @@ -12,7 +11,7 @@ use self::platform::*; pub struct Node { pub name: String, pub size: u64, - pub children: Vec>, + pub children: Vec, } pub fn simplify_dir_names(filenames: Vec<&str>) -> HashSet { @@ -107,7 +106,7 @@ fn examine_dir( } } // 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 s = data.entry(path_name.to_string()).or_insert(0); *s += size;