Struct comrak::arena_tree::Node
source · [−]pub struct Node<'a, T: 'a> {
pub data: T,
/* private fields */
}Expand description
A node inside a DOM-like tree.
Fields
data: TThe data held by the node.
Implementations
sourceimpl<'a, T> Node<'a, T>
impl<'a, T> Node<'a, T>
sourcepub fn new(data: T) -> Node<'a, T>
pub fn new(data: T) -> Node<'a, T>
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.
sourcepub fn parent(&self) -> Option<&'a Node<'a, T>>
pub fn parent(&self) -> Option<&'a Node<'a, T>>
Return a reference to the parent node, unless this node is the root of the tree.
sourcepub fn first_child(&self) -> Option<&'a Node<'a, T>>
pub fn first_child(&self) -> Option<&'a Node<'a, T>>
Return a reference to the first child of this node, unless it has no child.
sourcepub fn last_child(&self) -> Option<&'a Node<'a, T>>
pub fn last_child(&self) -> Option<&'a Node<'a, T>>
Return a reference to the last child of this node, unless it has no child.
sourcepub fn previous_sibling(&self) -> Option<&'a Node<'a, T>>
pub fn previous_sibling(&self) -> Option<&'a Node<'a, T>>
Return a reference to the previous sibling of this node, unless it is a first child.
sourcepub fn next_sibling(&self) -> Option<&'a Node<'a, T>>
pub fn next_sibling(&self) -> Option<&'a Node<'a, T>>
Return a reference to the previous sibling of this node, unless it is a last child.
sourcepub fn same_node(&self, other: &Node<'a, T>) -> bool
pub fn same_node(&self, other: &Node<'a, T>) -> bool
Returns whether two references point to the same node.
sourcepub fn ancestors(&'a self) -> Ancestors<'a, T>ⓘNotable traits for Ancestors<'a, T>impl<'a, T> Iterator for Ancestors<'a, T> type Item = &'a Node<'a, T>;
pub fn ancestors(&'a self) -> Ancestors<'a, T>ⓘNotable traits for Ancestors<'a, T>impl<'a, T> Iterator for Ancestors<'a, T> type Item = &'a Node<'a, T>;
Return an iterator of references to this node and its ancestors.
Call .next().unwrap() once on the iterator to skip the node itself.
sourcepub fn preceding_siblings(&'a self) -> PrecedingSiblings<'a, T>ⓘNotable traits for PrecedingSiblings<'a, T>impl<'a, T> Iterator for PrecedingSiblings<'a, T> type Item = &'a Node<'a, T>;
pub fn preceding_siblings(&'a self) -> PrecedingSiblings<'a, T>ⓘNotable traits for PrecedingSiblings<'a, T>impl<'a, T> Iterator for PrecedingSiblings<'a, T> type Item = &'a Node<'a, T>;
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.
sourcepub fn following_siblings(&'a self) -> FollowingSiblings<'a, T>ⓘNotable traits for FollowingSiblings<'a, T>impl<'a, T> Iterator for FollowingSiblings<'a, T> type Item = &'a Node<'a, T>;
pub fn following_siblings(&'a self) -> FollowingSiblings<'a, T>ⓘNotable traits for FollowingSiblings<'a, T>impl<'a, T> Iterator for FollowingSiblings<'a, T> type Item = &'a Node<'a, T>;
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.
sourcepub fn children(&'a self) -> Children<'a, T>ⓘNotable traits for Children<'a, T>impl<'a, T> Iterator for Children<'a, T> type Item = &'a Node<'a, T>;
pub fn children(&'a self) -> Children<'a, T>ⓘNotable traits for Children<'a, T>impl<'a, T> Iterator for Children<'a, T> type Item = &'a Node<'a, T>;
Return an iterator of references to this node’s children.
sourcepub fn reverse_children(&'a self) -> ReverseChildren<'a, T>ⓘNotable traits for ReverseChildren<'a, T>impl<'a, T> Iterator for ReverseChildren<'a, T> type Item = &'a Node<'a, T>;
pub fn reverse_children(&'a self) -> ReverseChildren<'a, T>ⓘNotable traits for ReverseChildren<'a, T>impl<'a, T> Iterator for ReverseChildren<'a, T> type Item = &'a Node<'a, T>;
Return an iterator of references to this node’s children, in reverse order.
sourcepub fn descendants(&'a self) -> Descendants<'a, T>ⓘNotable traits for Descendants<'a, T>impl<'a, T> Iterator for Descendants<'a, T> type Item = &'a Node<'a, T>;
pub fn descendants(&'a self) -> Descendants<'a, T>ⓘNotable traits for Descendants<'a, T>impl<'a, T> Iterator for Descendants<'a, T> type Item = &'a Node<'a, T>;
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.
sourcepub fn traverse(&'a self) -> Traverse<'a, T>ⓘNotable traits for Traverse<'a, T>impl<'a, T> Iterator for Traverse<'a, T> type Item = NodeEdge<&'a Node<'a, T>>;
pub fn traverse(&'a self) -> Traverse<'a, T>ⓘNotable traits for Traverse<'a, T>impl<'a, T> Iterator for Traverse<'a, T> type Item = NodeEdge<&'a Node<'a, T>>;
Return an iterator of references to this node and its descendants, in tree order.
sourcepub fn reverse_traverse(&'a self) -> ReverseTraverse<'a, T>ⓘNotable traits for ReverseTraverse<'a, T>impl<'a, T> Iterator for ReverseTraverse<'a, T> type Item = NodeEdge<&'a Node<'a, T>>;
pub fn reverse_traverse(&'a self) -> ReverseTraverse<'a, T>ⓘNotable traits for ReverseTraverse<'a, T>impl<'a, T> Iterator for ReverseTraverse<'a, T> type Item = NodeEdge<&'a Node<'a, T>>;
Return an iterator of references to this node and its descendants, in tree order.
sourcepub fn append(&'a self, new_child: &'a Node<'a, T>)
pub fn append(&'a self, new_child: &'a Node<'a, T>)
Append a new child to this node, after existing children.
sourcepub fn prepend(&'a self, new_child: &'a Node<'a, T>)
pub fn prepend(&'a self, new_child: &'a Node<'a, T>)
Prepend a new child to this node, before existing children.
sourcepub fn insert_after(&'a self, new_sibling: &'a Node<'a, T>)
pub fn insert_after(&'a self, new_sibling: &'a Node<'a, T>)
Insert a new sibling after this node.
sourcepub fn insert_before(&'a self, new_sibling: &'a Node<'a, T>)
pub fn insert_before(&'a self, new_sibling: &'a Node<'a, T>)
Insert a new sibling before this node.
Trait Implementations
Auto Trait Implementations
impl<'a, T> !RefUnwindSafe for Node<'a, T>
impl<'a, T> !Send for Node<'a, T>
impl<'a, T> !Sync for Node<'a, T>
impl<'a, T> Unpin for Node<'a, T> where
T: Unpin,
impl<'a, T> !UnwindSafe for Node<'a, T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more