[][src]Struct comrak::arena_tree::Node

pub struct Node<'a, T: 'a> {
    pub data: T,
    // some fields omitted
}

A node inside a DOM-like tree.

Fields

data: T

The data held by the node.

Methods

impl<'a, T> Node<'a, T>[src]

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

Create a new node from its associated data.

Typically, this node needs to be moved into an arena allocator before it can be used in a tree.

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

Return a reference to the parent node, unless this node is the root of the tree.

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

Return a reference to the first child of this node, unless it has no child.

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

Return a reference to the last child of this node, unless it has no child.

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

Return a reference to the previous sibling of this node, unless it is a first child.

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

Return a reference to the previous sibling of this node, unless it is a last child.

pub fn same_node(&self, other: &Node<'a, T>) -> bool[src]

Returns whether two references point to the same node.

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

Return an iterator of references to this node and its ancestors.

Call .next().unwrap() once on the iterator to skip the node itself.

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

Return an iterator of references to this node and the siblings before it.

Call .next().unwrap() once on the iterator to skip the node itself.

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

Return an iterator of references to this node and the siblings after it.

Call .next().unwrap() once on the iterator to skip the node itself.

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

Return an iterator of references to this node’s children.

Important traits for ReverseChildren<'a, T>
pub fn reverse_children(&'a self) -> ReverseChildren<'a, T>[src]

Return an iterator of references to this node’s children, in reverse order.

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

Return an iterator of references to this node and its descendants, in tree order.

Parent nodes appear before the descendants. Call .next().unwrap() once on the iterator to skip the node itself.

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

Return an iterator of references to this node and its descendants, in tree order.

Important traits for ReverseTraverse<'a, T>
pub fn reverse_traverse(&'a self) -> ReverseTraverse<'a, T>[src]

Return an iterator of references to this node and its descendants, in tree order.

pub fn detach(&self)[src]

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

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

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

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

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

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

Insert a new sibling after this node.

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

Insert a new sibling before this node.

Trait Implementations

impl<'a, T: 'a> Debug for Node<'a, T> where
    T: Debug
[src]

A simple Debug implementation that prints the children as a tree, without ilooping through the various interior pointer cycles.

Auto Trait Implementations

impl<'a, T> !Send for Node<'a, T>

impl<'a, T> !Sync for Node<'a, T>

Blanket Implementations

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.

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]