pub trait NodeToken<N: Node>:
Idx
+ Copy
+ PartialEq
+ Debug {
Show 26 methods
// Provided methods
fn parent(
&self,
arena: &Arena<N::Base>,
) -> Option<<<N::Base as BaseNode>::Branch as Node>::Token> { ... }
fn ancestors<'arena>(
&self,
arena: &'arena Arena<N::Base>,
) -> Ancestors<'arena, N::Base> ⓘ { ... }
fn root<'arena>(&self, arena: &'arena Arena<N::Base>) -> RootToken<N>
where for<'base> &'base N: TryFrom<&'base N::Base>,
for<'base> <&'base N as TryFrom<&'base N::Base>>::Error: Debug { ... }
fn data<'arena>(&self, arena: &'arena Arena<N::Base>) -> N::DataRef<'arena>
where for<'base> &'base N: TryFrom<&'base N::Base>,
for<'base> <&'base N as TryFrom<&'base N::Base>>::Error: Debug { ... }
fn data_mut<'arena>(
&self,
arena: &'arena mut Arena<N::Base>,
) -> N::DataRefMut<'arena>
where for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug { ... }
fn prev(&self, arena: &Arena<N::Base>) -> Option<<N::Base as Node>::Token>
where N::Base: LinkedNode { ... }
fn next(&self, arena: &Arena<N::Base>) -> Option<<N::Base as Node>::Token>
where N::Base: LinkedNode { ... }
fn preceding_siblings<'arena>(
&self,
arena: &'arena Arena<N::Base>,
) -> PrecedingSiblings<'arena, N> ⓘ
where N::Base: LinkedNode { ... }
fn following_siblings<'arena>(
&self,
arena: &'arena Arena<N::Base>,
) -> FollowingSiblings<'arena, N> ⓘ
where N::Base: LinkedNode { ... }
fn first(&self, arena: &Arena<N::Base>) -> Option<<N::Base as Node>::Token>
where N: BranchNode,
for<'base> &'base N: TryFrom<&'base N::Base>,
for<'base> <&'base N as TryFrom<&'base N::Base>>::Error: Debug { ... }
fn last(&self, arena: &Arena<N::Base>) -> Option<<N::Base as Node>::Token>
where N: BranchNode,
for<'base> &'base N: TryFrom<&'base N::Base>,
for<'base> <&'base N as TryFrom<&'base N::Base>>::Error: Debug { ... }
fn children<'arena>(
&self,
arena: &'arena Arena<N::Base>,
) -> N::ChildrenIter<'arena>
where N: BranchNode,
for<'base> &'base N: TryFrom<&'base N::Base>,
for<'base> <&'base N as TryFrom<&'base N::Base>>::Error: Debug { ... }
fn descendants<'arena>(
&self,
arena: &'arena Arena<N::Base>,
) -> Descendants<'arena, N> ⓘ
where N: BranchNode,
for<'base> &'base N: TryFrom<&'base N::Base>,
for<'base> <&'base N as TryFrom<&'base N::Base>>::Error: Debug { ... }
fn len(&self, arena: &Arena<N::Base>) -> usize
where N: BranchNodeDeque,
for<'base> &'base N: TryFrom<&'base N::Base>,
for<'base> <&'base N as TryFrom<&'base N::Base>>::Error: Debug { ... }
fn is_empty(&self, arena: &Arena<N::Base>) -> bool
where N: BranchNode,
for<'base> &'base N: TryFrom<&'base N::Base>,
for<'base> <&'base N as TryFrom<&'base N::Base>>::Error: Debug { ... }
fn get_unchecked(
&self,
arena: &Arena<N::Base>,
index: usize,
) -> <N::Base as Node>::Token
where N: BranchNodeDeque,
for<'base> &'base N: TryFrom<&'base N::Base>,
for<'base> <&'base N as TryFrom<&'base N::Base>>::Error: Debug { ... }
fn get(
&self,
arena: &Arena<N::Base>,
index: usize,
) -> Option<<N::Base as Node>::Token>
where N: BranchNodeDeque,
for<'base> &'base N: TryFrom<&'base N::Base>,
for<'base> <&'base N as TryFrom<&'base N::Base>>::Error: Debug { ... }
fn detach_front(
&self,
arena: &mut Arena<N::Base>,
) -> Option<<N::Base as Node>::Token>
where N: BranchNode<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug { ... }
fn detach_back(
&self,
arena: &mut Arena<N::Base>,
) -> Option<<N::Base as Node>::Token>
where N: BranchNode<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug { ... }
fn pop_front(
&self,
arena: &mut Arena<N::Base>,
) -> Option<<N::Base as BaseNode>::Representation>
where N: BranchNode<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug { ... }
fn pop_back(
&self,
arena: &mut Arena<N::Base>,
) -> Option<<N::Base as BaseNode>::Representation>
where N: BranchNode<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug { ... }
fn push_front(
&self,
arena: &mut Arena<N::Base>,
new: <N::Base as Node>::Token,
)
where N: BranchNode<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug { ... }
fn push_back(
&self,
arena: &mut Arena<N::Base>,
new: <N::Base as Node>::Token,
)
where N: BranchNode<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug { ... }
fn detach(
&self,
arena: &mut Arena<N::Base>,
index: usize,
) -> <N::Base as Node>::Token
where N: BranchNodeDeque<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug { ... }
fn remove(
&self,
arena: &mut Arena<N::Base>,
index: usize,
) -> <N::Base as BaseNode>::Representation
where N: BranchNodeDeque<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug { ... }
fn insert(
&self,
arena: &mut Arena<N::Base>,
index: usize,
new: <N::Base as Node>::Token,
)
where N: BranchNodeDeque<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug { ... }
}
Provided Methods§
Sourcefn parent(
&self,
arena: &Arena<N::Base>,
) -> Option<<<N::Base as BaseNode>::Branch as Node>::Token>
fn parent( &self, arena: &Arena<N::Base>, ) -> Option<<<N::Base as BaseNode>::Branch as Node>::Token>
Sourcefn root<'arena>(&self, arena: &'arena Arena<N::Base>) -> RootToken<N>
fn root<'arena>(&self, arena: &'arena Arena<N::Base>) -> RootToken<N>
Returns this node’s root node.
The root node is the most distant ancestor; it is the only node in a tree that does not have a parent.
If this node is the root node, RootToken::This
is returned. Otherwise,
RootToken::Ancestor
is returned with the root node’s token.
Internally, this method iterates over the node’s ancestors to find the last one, so it
is O(n)
best, average, and worst case.
Sourcefn data_mut<'arena>(
&self,
arena: &'arena mut Arena<N::Base>,
) -> N::DataRefMut<'arena>where
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug,
fn data_mut<'arena>(
&self,
arena: &'arena mut Arena<N::Base>,
) -> N::DataRefMut<'arena>where
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug,
Sourcefn prev(&self, arena: &Arena<N::Base>) -> Option<<N::Base as Node>::Token>where
N::Base: LinkedNode,
fn prev(&self, arena: &Arena<N::Base>) -> Option<<N::Base as Node>::Token>where
N::Base: LinkedNode,
Sourcefn next(&self, arena: &Arena<N::Base>) -> Option<<N::Base as Node>::Token>where
N::Base: LinkedNode,
fn next(&self, arena: &Arena<N::Base>) -> Option<<N::Base as Node>::Token>where
N::Base: LinkedNode,
Sourcefn preceding_siblings<'arena>(
&self,
arena: &'arena Arena<N::Base>,
) -> PrecedingSiblings<'arena, N> ⓘwhere
N::Base: LinkedNode,
fn preceding_siblings<'arena>(
&self,
arena: &'arena Arena<N::Base>,
) -> PrecedingSiblings<'arena, N> ⓘwhere
N::Base: LinkedNode,
Returns an iterator over the tokens of this node’s preceding siblings.
This iterator begins with the previous node and ends with the first child of the parent node.
If this is the first child, the iterator will be empty.
Sourcefn following_siblings<'arena>(
&self,
arena: &'arena Arena<N::Base>,
) -> FollowingSiblings<'arena, N> ⓘwhere
N::Base: LinkedNode,
fn following_siblings<'arena>(
&self,
arena: &'arena Arena<N::Base>,
) -> FollowingSiblings<'arena, N> ⓘwhere
N::Base: LinkedNode,
Returns an iterator over the tokens of this node’s following siblings.
This iterator begins with the next node and ends with the last child of the parent node.
If this is the last child, the iterator will be empty.
Sourcefn first(&self, arena: &Arena<N::Base>) -> Option<<N::Base as Node>::Token>
fn first(&self, arena: &Arena<N::Base>) -> Option<<N::Base as Node>::Token>
Returns the token of this branch node’s first child.
If this branch node has no children, None
is returned.
Sourcefn last(&self, arena: &Arena<N::Base>) -> Option<<N::Base as Node>::Token>
fn last(&self, arena: &Arena<N::Base>) -> Option<<N::Base as Node>::Token>
Returns the token of this branch node’s last child.
If this branch node has no children, None
is returned.
Sourcefn children<'arena>(
&self,
arena: &'arena Arena<N::Base>,
) -> N::ChildrenIter<'arena>
fn children<'arena>( &self, arena: &'arena Arena<N::Base>, ) -> N::ChildrenIter<'arena>
Returns an iterator over the tokens of this branch node’s children.
Sourcefn descendants<'arena>(
&self,
arena: &'arena Arena<N::Base>,
) -> Descendants<'arena, N> ⓘ
fn descendants<'arena>( &self, arena: &'arena Arena<N::Base>, ) -> Descendants<'arena, N> ⓘ
Returns an iterator over the tokens of this branch node’s descendants.
This iterator is a breadth-first traversal of the branch node’s descendants: its children are done first, then those children’s children in the same order, and so on and so on.
Sourcefn len(&self, arena: &Arena<N::Base>) -> usize
Available on crate feature deque
only.
fn len(&self, arena: &Arena<N::Base>) -> usize
deque
only.Returns the number of children this branch node has.
Sourcefn is_empty(&self, arena: &Arena<N::Base>) -> bool
fn is_empty(&self, arena: &Arena<N::Base>) -> bool
Returns whether this branch node has no children.
Sourcefn get_unchecked(
&self,
arena: &Arena<N::Base>,
index: usize,
) -> <N::Base as Node>::Token
Available on crate feature deque
only.
fn get_unchecked( &self, arena: &Arena<N::Base>, index: usize, ) -> <N::Base as Node>::Token
deque
only.Sourcefn get(
&self,
arena: &Arena<N::Base>,
index: usize,
) -> Option<<N::Base as Node>::Token>
Available on crate feature deque
only.
fn get( &self, arena: &Arena<N::Base>, index: usize, ) -> Option<<N::Base as Node>::Token>
deque
only.Returns the token of the child at the given index
.
If index
is out of bounds, None
is returned.
§See also
For a version without bounds checks, see get_unchecked
.
Sourcefn detach_front(
&self,
arena: &mut Arena<N::Base>,
) -> Option<<N::Base as Node>::Token>where
N: BranchNode<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug,
fn detach_front(
&self,
arena: &mut Arena<N::Base>,
) -> Option<<N::Base as Node>::Token>where
N: BranchNode<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug,
Detaches this branch node’s first child, returning its token.
If this branch node is empty then there is no child to detach, so None
is
returned. Otherwise, the child is removed from this branch node’s children, but
remains in the arena.
This function is useful if you want to move a node from one parent to another.
§See also
The last child may also be detached using detach_back
.
If this is a BranchNodeDeque
, children may also be detached by index using
detach
.
If you want to remove a child and its descendants from the arena altogether, see
pop_front
, pop_back
, or, if this is a BranchNodeDeque
, remove
.
Sourcefn detach_back(
&self,
arena: &mut Arena<N::Base>,
) -> Option<<N::Base as Node>::Token>where
N: BranchNode<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug,
fn detach_back(
&self,
arena: &mut Arena<N::Base>,
) -> Option<<N::Base as Node>::Token>where
N: BranchNode<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug,
Detaches this branch node’s last child, returning its token.
If this branch node is empty then there is no child to detach, so None
is
returned. Otherwise, the child is removed from this branch node’s children, but
remains in the arena.
This function is useful if you want to move a node from one parent to another.
§See also
The first child may also be detached using detach_front
.
If this is a BranchNodeDeque
, children may also be detached by index using
detach
.
If you want to remove a child and its descendants from the arena altogether, see
pop_front
, pop_back
, or, if this is a BranchNodeDeque
, remove
.
Sourcefn pop_front(
&self,
arena: &mut Arena<N::Base>,
) -> Option<<N::Base as BaseNode>::Representation>where
N: BranchNode<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug,
fn pop_front(
&self,
arena: &mut Arena<N::Base>,
) -> Option<<N::Base as BaseNode>::Representation>where
N: BranchNode<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug,
Removes this branch node’s first child.
If this branch node is empty then there is no child to remove, so None
is
returned. Otherwise, the removed node is returned.
§See also
The last child may also be removed using pop_back
.
If this is a BranchNodeDeque
, children may also be removed by index using
remove
.
If you don’t want to remove a child from the arena, but merely make it a root node
or move it to another parent, see
detach_front
, detach_back
, or, if this is a BranchNodeDeque
, detach
.
Sourcefn pop_back(
&self,
arena: &mut Arena<N::Base>,
) -> Option<<N::Base as BaseNode>::Representation>where
N: BranchNode<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug,
fn pop_back(
&self,
arena: &mut Arena<N::Base>,
) -> Option<<N::Base as BaseNode>::Representation>where
N: BranchNode<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug,
Removes this branch node’s last child.
If this branch node is empty then there is no child to remove, so None
is
returned. Otherwise, the removed node is returned.
§See also
The first child may also be removed using pop_front
.
If this is a BranchNodeDeque
, children may also be removed by index using
remove
.
If you don’t want to remove a child from the arena, but merely make it a root node
or move it to another parent, see
detach_front
, detach_back
, or, if this is a BranchNodeDeque
, detach
.
Sourcefn push_front(&self, arena: &mut Arena<N::Base>, new: <N::Base as Node>::Token)where
N: BranchNode<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug,
fn push_front(&self, arena: &mut Arena<N::Base>, new: <N::Base as Node>::Token)where
N: BranchNode<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug,
Pushes the given new
token’s node to the beginning of this branch node’s
children.
§Panics
This method will panic if the given new
token refers to either:
§See also
A child may also be pushed to the end with push_back
.
If this is a BranchNodeDeque
, children may also be inserted by index using
insert
.
Sourcefn push_back(&self, arena: &mut Arena<N::Base>, new: <N::Base as Node>::Token)where
N: BranchNode<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug,
fn push_back(&self, arena: &mut Arena<N::Base>, new: <N::Base as Node>::Token)where
N: BranchNode<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug,
Pushes the given new
token’s node to the end of this branch node’s children.
§Panics
This method will panic if the given new
token refers to either:
§See also
A child may also be pushed to the beginning with push_front
. If this is a
BranchNodeDeque
, children may also be inserted by index using insert
.
If this is a BranchNodeDeque
, children may also be inserted by index using
insert
.
Sourcefn detach(
&self,
arena: &mut Arena<N::Base>,
index: usize,
) -> <N::Base as Node>::Tokenwhere
N: BranchNodeDeque<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug,
Available on crate feature deque
only.
fn detach(
&self,
arena: &mut Arena<N::Base>,
index: usize,
) -> <N::Base as Node>::Tokenwhere
N: BranchNodeDeque<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug,
deque
only.Detaches the child at the given index
, returning its token.
This function is useful if you want to move a node from one parent to another.
§Panics
This method will panic if the given index
is out of bounds.
§See also
The first child or last child may be detached with detach_front
and detach_back
respectively.
If you want to remove a child and its descendents from the arena altogether, see
remove
, pop_front
, or pop_back
.
Sourcefn remove(
&self,
arena: &mut Arena<N::Base>,
index: usize,
) -> <N::Base as BaseNode>::Representationwhere
N: BranchNodeDeque<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug,
Available on crate feature deque
only.
fn remove(
&self,
arena: &mut Arena<N::Base>,
index: usize,
) -> <N::Base as BaseNode>::Representationwhere
N: BranchNodeDeque<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug,
deque
only.Removes the child at the given index
.
§Panics
This method will panic if the given index
is out of bounds.
§See also
The first child or last child may be removed with pop_front
and pop_back
respectively.
If you don’t want to remove a child from the arena, but merely make it a root node or
move it to another parent, see detach
, detach_front
, or detach_back
.
Sourcefn insert(
&self,
arena: &mut Arena<N::Base>,
index: usize,
new: <N::Base as Node>::Token,
)where
N: BranchNodeDeque<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug,
Available on crate feature deque
only.
fn insert(
&self,
arena: &mut Arena<N::Base>,
index: usize,
new: <N::Base as Node>::Token,
)where
N: BranchNodeDeque<Token = Self>,
for<'base> &'base mut N: TryFrom<&'base mut N::Base>,
for<'base> <&'base mut N as TryFrom<&'base mut N::Base>>::Error: Debug,
deque
only.Inserts the given new
token’s node at the given index
.
§Panics
This method will panic if:
§See also
A child can also be pushed to the beginning or end of this branch node’s children with
push_front
and push_back
respectively.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
impl<BranchData, LeafData> NodeToken<SplitNode<BranchData, LeafData>> for SplitToken<BranchData, LeafData>
split
only.impl<BranchData, LeafData> NodeToken<SplitNodeDeque<BranchData, LeafData>> for SplitTokenDeque<BranchData, LeafData>
deque
and split
only.