pub struct Tree<T> { /* private fields */ }
Expand description
Implementations§
Source§impl<T> Tree<T>
impl<T> Tree<T>
Sourcepub fn as_node(&self) -> Node<'_, T>
pub fn as_node(&self) -> Node<'_, T>
Returns the unique root node of the tree representing the entire tree.
You can think of this as taking the complete slice of the tree similar
to &vec[..]
for a Vec
<T>
.
Sourcepub fn get(&self, rank: usize) -> Option<Node<'_, T>>
pub fn get(&self, rank: usize) -> Option<Node<'_, T>>
Returns the node with the specified rank
.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of nodes in the tree.
Because trees are required to have exactly one root node, the length
will always be at least 1
.
Sourcepub fn into_sapling(self) -> Sapling<T>
pub fn into_sapling(self) -> Sapling<T>
Turns the tree back into a sapling. No nodes are removed from the tree; building the returned sapling will result in the original tree.
All internal buffers are reused, making this a cheap operation. The only
cost of converting Sapling
<T>
s and Tree
<T>
s back and forth
is the validation that occurs during build
.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Tree<T>
impl<T> RefUnwindSafe for Tree<T>where
T: RefUnwindSafe,
impl<T> Send for Tree<T>where
T: Send,
impl<T> Sync for Tree<T>where
T: Sync,
impl<T> Unpin for Tree<T>where
T: Unpin,
impl<T> UnwindSafe for Tree<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more