[][src]Struct rctree::Node

pub struct Node<T>(_);

A reference to a node holding a value of type T. Nodes form a tree.

Internally, this uses reference counting for lifetime tracking and std::cell::RefCell for interior mutability.

Note: Cloning a Node only increments a reference count. It does not copy the data.

Methods

impl<T> Node<T>[src]

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

Creates a new node from its associated data.

pub fn downgrade(&self) -> WeakNode<T>[src]

Returns a weak referece to a node.

pub fn root(&self) -> Node<T>[src]

Returns a root node.

If the current node is the root node - will return itself.

Panics

Panics if the node is currently mutably borrowed.

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

Returns a parent node, unless this node is the root of the tree.

Panics

Panics if the node is currently mutably borrowed.

pub fn first_child(&self) -> Option<Node<T>>[src]

Returns a first child of this node, unless it has no child.

Panics

Panics if the node is currently mutably borrowed.

pub fn last_child(&self) -> Option<Node<T>>[src]

Returns a last child of this node, unless it has no child.

Panics

Panics if the node is currently mutably borrowed.

pub fn previous_sibling(&self) -> Option<Node<T>>[src]

Returns the previous sibling of this node, unless it is a first child.

Panics

Panics if the node is currently mutably borrowed.

pub fn next_sibling(&self) -> Option<Node<T>>[src]

Returns the next sibling of this node, unless it is a last child.

Panics

Panics if the node is currently mutably borrowed.

pub fn borrow(&self) -> Ref<T>[src]

Returns a shared reference to this node's data

Panics

Panics if the node is currently mutably borrowed.

pub fn borrow_mut(&mut self) -> RefMut<T>[src]

Returns a unique/mutable reference to this node's data

Panics

Panics if the node is currently borrowed.

Important traits for Ancestors<T>
pub fn ancestors(&self) -> Ancestors<T>[src]

Returns an iterator of nodes to this node and its ancestors.

Includes the current node.

Important traits for PrecedingSiblings<T>
pub fn preceding_siblings(&self) -> PrecedingSiblings<T>[src]

Returns an iterator of nodes to this node and the siblings before it.

Includes the current node.

Important traits for FollowingSiblings<T>
pub fn following_siblings(&self) -> FollowingSiblings<T>[src]

Returns an iterator of nodes to this node and the siblings after it.

Includes the current node.

Important traits for Children<T>
pub fn children(&self) -> Children<T>[src]

Returns an iterator of nodes to this node's children.

Panics

Panics if the node is currently mutably borrowed.

pub fn has_children(&self) -> bool[src]

Returns true if this node has children nodes.

Panics

Panics if the node is currently mutably borrowed.

Important traits for Descendants<T>
pub fn descendants(&self) -> Descendants<T>[src]

Returns an iterator of nodes to this node and its descendants, in tree order.

Includes the current node.

Important traits for Traverse<T>
pub fn traverse(&self) -> Traverse<T>[src]

Returns an iterator of nodes to this node and its descendants, in tree order.

pub fn detach(&mut self)[src]

Detaches a node from its parent and siblings. Children are not affected.

Panics

Panics if the node or one of its adjoining nodes is currently borrowed.

pub fn append(&mut self, new_child: Node<T>)[src]

Appends a new child to this node, after existing children.

Panics

Panics if the node, the new child, or one of their adjoining nodes is currently borrowed.

pub fn prepend(&mut self, new_child: Node<T>)[src]

Prepends a new child to this node, before existing children.

Panics

Panics if the node, the new child, or one of their adjoining nodes is currently borrowed.

pub fn insert_after(&mut self, new_sibling: Node<T>)[src]

Inserts a new sibling after this node.

Panics

Panics if the node, the new sibling, or one of their adjoining nodes is currently borrowed.

pub fn insert_before(&mut self, new_sibling: Node<T>)[src]

Inserts a new sibling before this node.

Panics

Panics if the node, the new sibling, or one of their adjoining nodes is currently borrowed.

pub fn make_copy(&mut self) -> Node<T> where
    T: Clone
[src]

Returns a copy of a current node without children.

Panics

Panics if the node is currently mutably borrowed.

pub fn make_deep_copy(&mut self) -> Node<T> where
    T: Clone
[src]

Returns a copy of a current node with children.

Panics

Panics if any of the descendant nodes are currently mutably borrowed.

Trait Implementations

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

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

This method tests for !=.

impl<T> Clone for Node<T>[src]

Cloning a Node only increments a reference count. It does not copy the data.

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

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

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

Auto Trait Implementations

impl<T> !Send for Node<T>

impl<T> !Sync for Node<T>

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From<T> for 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.

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

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

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