Struct arena_tree::NodeRef
[−]
[src]
pub struct NodeRef<'a, T: 'a>(_);
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 NodeRef only copies a pointer. It does not copy the data.
Methods
impl<'a, T> NodeRef<'a, T>[src]
fn parent(self) -> Option<NodeRef<'a, T>>
Return a reference to the parent node, unless this node is the root of the tree.
Panics
Panics if the node is currently mutability borrowed.
fn first_child(self) -> Option<NodeRef<'a, T>>
Return a reference to the first child of this node, unless it has no child.
Panics
Panics if the node is currently mutability borrowed.
fn last_child(self) -> Option<NodeRef<'a, T>>
Return a reference to the last child of this node, unless it has no child.
Panics
Panics if the node is currently mutability borrowed.
fn previous_sibling(self) -> Option<NodeRef<'a, T>>
Return a reference to the previous sibling of this node, unless it is a first child.
Panics
Panics if the node is currently mutability borrowed.
fn next_sibling(self) -> Option<NodeRef<'a, T>>
Return a reference to the previous sibling of this node, unless it is a first child.
Panics
Panics if the node is currently mutability borrowed.
fn borrow(self) -> Ref<'a, T>
Return a shared reference to this node’s data
Panics
Panics if the node is currently mutability borrowed.
fn borrow_mut(self) -> RefMut<'a, T>
Return a unique/mutable reference to this node’s data
Panics
Panics if the node is currently borrowed.
fn same_node(self, other: NodeRef<'a, T>) -> bool
Returns whether two references point to the same node.
fn ancestors(self) -> Ancestors<'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.
fn preceding_siblings(self) -> PrecedingSiblings<'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.
fn following_siblings(self) -> FollowingSiblings<'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.
fn children(self) -> Children<'a, T>
Return an iterator of references to this node’s children.
Panics
Panics if the node is currently mutability borrowed.
fn reverse_children(self) -> ReverseChildren<'a, T>
Return an iterator of references to this node’s children, in reverse order.
Panics
Panics if the node is currently mutability borrowed.
fn descendants(self) -> Descendants<'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.
fn traverse(self) -> Traverse<'a, T>
Return an iterator of references to this node and its descendants, in tree order.
fn reverse_traverse(self) -> ReverseTraverse<'a, T>
Return an iterator of references to this node and its descendants, in tree order.
fn detach(self)
Detach 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.
fn append(self, new_child: NodeRef<'a, T>)
Append 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.
fn prepend(self, new_child: NodeRef<'a, T>)
Prepend 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.
fn insert_after(self, new_sibling: NodeRef<'a, T>)
Insert a new sibling after this node.
Panics
Panics if the node, the new sibling, or one of their adjoining nodes is currently borrowed.
fn insert_before(self, new_sibling: NodeRef<'a, T>)
Insert a new sibling before this node.
Panics
Panics if the node, the new sibling, or one of their adjoining nodes is currently borrowed.
Trait Implementations
impl<'a, T> Copy for NodeRef<'a, T>[src]
impl<'a, T> Clone for NodeRef<'a, T>[src]
Cloning a node reference does not clone the node itself, it only copies a pointer.
fn clone(&self) -> NodeRef<'a, T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0
Performs copy-assignment from source. Read more