pub trait BranchNode: Node {
type ChildrenIter<'branch>: DoubleEndedIterator<Item = <Self::Base as Node>::Token> + FusedIterator
where Self: 'branch;
// Required methods
fn first(&self) -> Option<<Self::Base as Node>::Token>;
fn last(&self) -> Option<<Self::Base as Node>::Token>;
fn children<'branch>(
&'branch self,
arena: &'branch Arena<Self::Base>,
) -> Self::ChildrenIter<'branch>;
fn is_empty(&self) -> bool;
fn detach_front(
token: Self::Token,
arena: &mut Arena<Self::Base>,
) -> Option<<Self::Base as Node>::Token>
where Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug;
fn detach_back(
token: Self::Token,
arena: &mut Arena<Self::Base>,
) -> Option<<Self::Base as Node>::Token>
where Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug;
fn pop_front(
token: Self::Token,
arena: &mut Arena<Self::Base>,
) -> Option<<Self::Base as BaseNode>::Representation>
where Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug;
fn pop_back(
token: Self::Token,
arena: &mut Arena<Self::Base>,
) -> Option<<Self::Base as BaseNode>::Representation>
where Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug;
fn push_front(
token: Self::Token,
arena: &mut Arena<Self::Base>,
new: <Self::Base as Node>::Token,
)
where Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug;
fn push_back(
token: Self::Token,
arena: &mut Arena<Self::Base>,
new: <Self::Base as Node>::Token,
)
where Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug;
// Provided method
fn descendants<'branch>(
&'branch self,
arena: &'branch Arena<Self::Base>,
) -> Descendants<'branch, Self> ⓘ
where Self: Sized,
for<'base> &'base Self: TryFrom<&'base Self::Base> { ... }
}
Required Associated Types§
Sourcetype ChildrenIter<'branch>: DoubleEndedIterator<Item = <Self::Base as Node>::Token> + FusedIterator
where
Self: 'branch
type ChildrenIter<'branch>: DoubleEndedIterator<Item = <Self::Base as Node>::Token> + FusedIterator where Self: 'branch
The iterator returned by children
.
Required Methods§
Sourcefn children<'branch>(
&'branch self,
arena: &'branch Arena<Self::Base>,
) -> Self::ChildrenIter<'branch>
fn children<'branch>( &'branch self, arena: &'branch Arena<Self::Base>, ) -> Self::ChildrenIter<'branch>
Returns an iterator over the tokens of this branch node’s children.
Sourcefn detach_front(
token: Self::Token,
arena: &mut Arena<Self::Base>,
) -> Option<<Self::Base as Node>::Token>
fn detach_front( token: Self::Token, arena: &mut Arena<Self::Base>, ) -> Option<<Self::Base as Node>::Token>
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.
This function takes its token as a parameter instead of &mut self
as a receiver to
avoid having multiple mutable references into the arena at a time.
§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(
token: Self::Token,
arena: &mut Arena<Self::Base>,
) -> Option<<Self::Base as Node>::Token>
fn detach_back( token: Self::Token, arena: &mut Arena<Self::Base>, ) -> Option<<Self::Base as Node>::Token>
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.
This function takes its token as a parameter instead of &mut self
as a receiver to
avoid having multiple mutable references into the arena at a time.
§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(
token: Self::Token,
arena: &mut Arena<Self::Base>,
) -> Option<<Self::Base as BaseNode>::Representation>
fn pop_front( token: Self::Token, arena: &mut Arena<Self::Base>, ) -> Option<<Self::Base as BaseNode>::Representation>
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.
This function takes its token as a parameter instead of &mut self
as a receiver to
avoid having multiple mutable references into the arena at a time.
§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(
token: Self::Token,
arena: &mut Arena<Self::Base>,
) -> Option<<Self::Base as BaseNode>::Representation>
fn pop_back( token: Self::Token, arena: &mut Arena<Self::Base>, ) -> Option<<Self::Base as BaseNode>::Representation>
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.
This function takes its token as a parameter instead of &mut self
as a receiver
avoid having multiple mutable references into the arena at a time.
§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(
token: Self::Token,
arena: &mut Arena<Self::Base>,
new: <Self::Base as Node>::Token,
)
fn push_front( token: Self::Token, arena: &mut Arena<Self::Base>, new: <Self::Base as Node>::Token, )
Pushes the given new
token’s node to the beginning of this branch node’s
children.
This function takes its token as a parameter instead of &mut self
as a receiver to
avoid having multiple mutable references into the arena at a time.
§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(
token: Self::Token,
arena: &mut Arena<Self::Base>,
new: <Self::Base as Node>::Token,
)
fn push_back( token: Self::Token, arena: &mut Arena<Self::Base>, new: <Self::Base as Node>::Token, )
Pushes the given new
token’s node to the end of this branch node’s children.
This function takes its token as a parameter instead of &mut self
as a receiver to
avoid having multiple mutable references into the arena at a time.
§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
.
Provided Methods§
Sourcefn descendants<'branch>(
&'branch self,
arena: &'branch Arena<Self::Base>,
) -> Descendants<'branch, Self> ⓘ
fn descendants<'branch>( &'branch self, arena: &'branch Arena<Self::Base>, ) -> Descendants<'branch, Self> ⓘ
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§
Source§impl<BranchData, LeafData> BranchNode for Branch<BranchData, LeafData>
Available on crate feature split
only.
impl<BranchData, LeafData> BranchNode for Branch<BranchData, LeafData>
split
only.type ChildrenIter<'branch> = ChildrenLinked<'branch, Branch<BranchData, LeafData>> where Self: 'branch
Source§impl<BranchData, LeafData> BranchNode for BranchDeque<BranchData, LeafData>
Available on crate features deque
and split
only.
impl<BranchData, LeafData> BranchNode for BranchDeque<BranchData, LeafData>
deque
and split
only.type ChildrenIter<'branch> = Copied<Iter<'branch, <<BranchDeque<BranchData, LeafData> as Node>::Base as Node>::Token>> where Self: 'branch
Source§impl<Data: Debug> BranchNode for UnifiedNode<Data>
Available on crate feature unified
only.
impl<Data: Debug> BranchNode for UnifiedNode<Data>
unified
only.type ChildrenIter<'branch> = ChildrenLinked<'branch, UnifiedNode<Data>> where Self: 'branch
Source§impl<Data: Debug> BranchNode for UnifiedNodeDeque<Data>
Available on crate features deque
and unified
only.
impl<Data: Debug> BranchNode for UnifiedNodeDeque<Data>
deque
and unified
only.