[][src]Struct id_tree::Node

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

A container that wraps data in a given Tree.

Methods

impl<T> Node<T>[src]

pub fn new(data: T) -> Node<T>[src]

Creates a new Node with the data provided.

use id_tree::Node;

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

pub fn data(&self) -> &T[src]

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

pub fn data_mut(&mut self) -> &mut T[src]

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

pub fn replace_data(&mut self, data: T) -> T[src]

Replaces this Nodes data with the data provided.

Returns the old value of data.

use id_tree::Node;

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

// ops! lets correct this
let three = node_four.replace_data(4);

assert_eq!(node_four.data(), &4);
assert_eq!(three, 3);

pub fn parent(&self) -> Option<&NodeId>[src]

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

pub fn children(&self) -> &Vec<NodeId>[src]

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

Trait Implementations

impl<T> PartialEq<Node<T>> for Node<T> where
    T: PartialEq
[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl<T: Debug> Debug for Node<T>[src]

Auto Trait Implementations

impl<T> Send for Node<T> where
    T: Send

impl<T> Sync for Node<T> where
    T: Sync

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.