Struct id_tree::Node [] [src]

pub struct Node<T> { /* fields omitted */ }

A container that wraps data in a given Tree.

Methods

impl<T> Node<T>
[src]

Creates a new Node with the data provided.

use id_tree::Node;

let _one: Node<i32> = Node::new(1);

Returns an immutable reference to the data contained within the Node.

use id_tree::Node;

let node_three: Node<i32> = Node::new(3);
let three = 3;

assert_eq!(node_three.data(), &three);

Returns a mutable reference to the data contained within the Node.

use id_tree::Node;

let mut node_four: Node<i32> = Node::new(4);
let mut four = 4;

assert_eq!(node_four.data_mut(), &mut four);

Returns a Some value containing the NodeId of this Node's parent if it exists; returns None if it does not.

Note: A Node cannot have a parent until after it has been inserted into a Tree.

use id_tree::Node;

let five: Node<i32> = Node::new(5);

assert!(five.parent().is_none());

Returns an immutable reference to a Vec containing the NodeIds of this Node's children.

Note: A Node cannot have any children until after it has been inserted into a Tree.

use id_tree::Node;

let six: Node<i32> = Node::new(6);

assert_eq!(six.children().len(), 0);