[−][src]Struct id_tree::Node
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 Node
s 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 NodeId
s 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]
T: PartialEq,
fn eq(&self, other: &Node<T>) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=
.
impl<T: Debug> Debug for Node<T>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,