pub type DynNode<'a, T, M = Auto, P = SplitRecursive> = Node<'a, Dyn<T>, M, P>;
Expand description
Node of a DynTree
.
Aliased TypeΒ§
pub struct DynNode<'a, T, M = Auto, P = SplitRecursive> { /* private fields */ }
Trait Implementations
SourceΒ§impl<V, M, P> Display for Node<'_, V, M, P>
impl<V, M, P> Display for Node<'_, V, M, P>
SourceΒ§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Creates a convenient-to-read string representation of the tree or a subtree rooted at a node.
Β§Examples
use orx_tree::*;
// 1
// β± β²
// β± β²
// 2 3
// β± β² β± β²
// 4 5 6 7
// | | β± β²
// 8 9 10 11
let mut tree = DynTree::new(1);
let mut root = tree.root_mut();
let [id2, id3] = root.push_children([2, 3]);
let [id4, _] = tree.node_mut(&id2).push_children([4, 5]);
tree.node_mut(&id4).push_child(8);
let [id6, id7] = tree.node_mut(&id3).push_children([6, 7]);
tree.node_mut(&id6).push_child(9);
tree.node_mut(&id7).push_children([10, 11]);
let expected_str = r#"1
βββ2
β βββ4
β β βββ8
β βββ5
βββ3
βββ6
β βββ9
βββ7
βββ10
βββ11
"#;
assert_eq!(tree.to_string(), expected_str);
let expected_str = r#"3
βββ6
β βββ9
βββ7
βββ10
βββ11
"#;
println!("{}", tree.node(&id3).to_string());
assert_eq!(tree.node(&id3).to_string(), expected_str);