simplify the tree structure code

master
Able 2021-11-30 13:52:31 -06:00
parent 1229d8844a
commit 0188fccc07
No known key found for this signature in database
GPG Key ID: 2BB8F62388A6A225
1 changed files with 2 additions and 6 deletions

View File

@ -15,7 +15,7 @@ impl File {
fn new(name: String) -> Self {
Self {
size: *&name.len() as u64,
name: name,
name,
}
}
}
@ -36,11 +36,7 @@ fn main() {
for x in tree.traverse_pre_order(&root_id.unwrap()).unwrap() {
println!("Parent: {:?}", x.data());
for y in x.children() {
if tree.get(y).unwrap().children().is_empty() {
println!("No Children");
} else {
println!(" Children: {:?}", tree.get(y).unwrap().data());
}
println!(" Children: {:?}", tree.get(y).unwrap().data());
}
}
}