From fd35734a94d32d8efbe658cf1e006c28ec0e5aa4 Mon Sep 17 00:00:00 2001 From: "andy.boot" Date: Wed, 2 Oct 2019 19:48:57 +0100 Subject: [PATCH] Simplify string code, remove into --- src/display.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/display.rs b/src/display.rs index 63e7418..9452571 100644 --- a/src/display.rs +++ b/src/display.rs @@ -35,14 +35,14 @@ fn get_size(nodes: &[(String, u64)], node_to_print: &str) -> Option { None } -fn display_node>( +fn display_node( node_to_print: &str, found: &mut HashSet, to_display: &[(String, u64)], is_biggest: bool, short_paths: bool, depth: Option, - indentation_str: S, + indentation_str: &str, ) { if found.contains(node_to_print) { return; @@ -57,9 +57,8 @@ fn display_node>( match get_size(to_display, node_to_print) { None => println!("Can not find path: {}", node_to_print), Some(size) => { - let is = indentation_str.into(); - print_this_node(node_to_print, size, is_biggest, short_paths, is.as_ref()); - let new_indent = clean_indentation_string(is); + print_this_node(node_to_print, size, is_biggest, short_paths, indentation_str); + let new_indent = clean_indentation_string(indentation_str); let ntp_with_slash = strip_end_slash(node_to_print); @@ -84,7 +83,7 @@ fn display_node>( is_biggest, short_paths, new_depth, - new_indent.to_string() + get_tree_chars(num_siblings != 0, has_children), + &*(new_indent.to_string() + get_tree_chars(num_siblings != 0, has_children)), ); is_biggest = false; } @@ -93,8 +92,8 @@ fn display_node>( } } -fn clean_indentation_string>(s: S) -> String { - let mut is = s.into(); +fn clean_indentation_string(s: &str) -> String { + let mut is :String = s.into(); is = is.replace("└─┬", " "); is = is.replace("└──", " "); is = is.replace("├──", "│ ");