[][src]Enum id_tree::InsertBehavior

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();

Auto Trait Implementations

impl<'a> Send for InsertBehavior<'a>

impl<'a> Sync for InsertBehavior<'a>

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.