simplify the tree structure code
This commit is contained in:
parent
f5e30e15fb
commit
e9e3749d85
|
@ -15,7 +15,7 @@ impl File {
|
||||||
fn new(name: String) -> Self {
|
fn new(name: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
size: *&name.len() as u64,
|
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() {
|
for x in tree.traverse_pre_order(&root_id.unwrap()).unwrap() {
|
||||||
println!("Parent: {:?}", x.data());
|
println!("Parent: {:?}", x.data());
|
||||||
for y in x.children() {
|
for y in x.children() {
|
||||||
if tree.get(y).unwrap().children().is_empty() {
|
println!(" Children: {:?}", tree.get(y).unwrap().data());
|
||||||
println!("No Children");
|
|
||||||
} else {
|
|
||||||
println!(" Children: {:?}", tree.get(y).unwrap().data());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue