Enum id_tree::InsertBehavior
[−]
[src]
pub enum InsertBehavior<'a> { AsRoot, UnderNode(&'a NodeId), }
Describes the possible behaviors of the Tree::insert
method.
Variants
AsRoot
Sets the root of the Tree
.
If there is already a root Node
present in the tree, that Node
is set as the first child
of the new root.
use id_tree::*; use id_tree::InsertBehavior::*; let mut tree: Tree<i32> = Tree::new(); tree.insert(Node::new(5), AsRoot).unwrap();
UnderNode(&'a NodeId)
Returns a Result
containing the NodeId
of the child that was added or a NodeIdError
if
one occurred.
Note: Adds the new Node to the end of its children.
use id_tree::*; use id_tree::InsertBehavior::*; let root_node = Node::new(1); let child_node = Node::new(2); let mut tree: Tree<i32> = Tree::new(); let root_id = tree.insert(root_node, AsRoot).unwrap(); tree.insert(child_node, UnderNode(&root_id)).unwrap();