Type Alias DynNode

Source
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> Clone for Node<'_, V, M, P>

SourceΒ§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 Β· SourceΒ§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
SourceΒ§

impl<V, M, P> Debug for Node<'_, V, M, P>

SourceΒ§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
SourceΒ§

impl<V, M, P> Display for Node<'_, V, M, P>

SourceΒ§

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);
SourceΒ§

impl<'a, V, M, P> PartialEq<NodeMut<'a, V, M, P>> for Node<'_, V, M, P>

SourceΒ§

fn eq(&self, other: &NodeMut<'a, V, M, P>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 Β· SourceΒ§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
SourceΒ§

impl<V, M, P> PartialEq for Node<'_, V, M, P>

SourceΒ§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 Β· SourceΒ§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.