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,14 +36,10 @@ 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!("No Children");
|
|
||||||
} else {
|
|
||||||
println!(" Children: {:?}", tree.get(y).unwrap().data());
|
println!(" Children: {:?}", tree.get(y).unwrap().data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn generate_tree() {
|
fn generate_tree() {
|
||||||
let root_id: NodeId = FILE_TREE
|
let root_id: NodeId = FILE_TREE
|
||||||
|
|
Loading…
Reference in a new issue