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

Auto Trait Implementations

impl<'a> RefUnwindSafe for InsertBehavior<'a>

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

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

impl<'a> Unpin for InsertBehavior<'a>

impl<'a> UnwindSafe for InsertBehavior<'a>

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.