We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8f4f80e commit 95aaf8bCopy full SHA for 95aaf8b
examples/simple_tree.rs
@@ -0,0 +1,28 @@
1
+//! Implements this tree
2
+//! ```
3
+//! 1
4
+//! ├── 2
5
+//! └── 3
6
+//! ├── 4
7
+//! └── 5
8
9
+
10
+use ego_tree::{tree, NodeMut, Tree};
11
12
+fn main() {
13
+ // Manual construction of the tree
14
+ let mut tree: Tree<i32> = Tree::new(1);
15
+ let mut root: NodeMut<i32> = tree.root_mut();
16
+ root.append(2);
17
+ let mut child: NodeMut<i32> = root.append(3);
18
+ child.append(4);
19
+ child.append(5);
20
+ println!("Manual:\n{tree}");
21
22
+ // Construction of the tree through the tree! macro
23
+ let macro_tree: Tree<i32> = tree!(1 => {2, 3 => {4, 5}});
24
+ println!("Automated:\n{macro_tree}");
25
26
+ // Prooving equality
27
+ assert_eq!(tree, macro_tree);
28
+}
0 commit comments