pub trait Node: Debug + Sealed {
type Base: BaseNode;
type Token: NodeToken<Self>
where Self: Sized;
type Data;
type DataRef<'data>
where Self: 'data;
type DataRefMut<'data>
where Self: 'data;
// Required methods
fn new(arena: &mut Arena<Self::Base>, data: Self::Data) -> Self::Token
where Self: Sized;
fn token(&self) -> Self::Token
where Self: Sized;
fn parent(
&self,
) -> Option<<<Self::Base as BaseNode>::Branch as Node>::Token>;
fn data(&self) -> Self::DataRef<'_>;
fn data_mut(&mut self) -> Self::DataRefMut<'_>;
// Provided methods
fn ancestors<'node>(
&'node self,
arena: &'node Arena<Self::Base>,
) -> Ancestors<'node, Self::Base> ⓘ
where Self: Sized { ... }
fn root<'node>(
&'node self,
arena: &'node Arena<Self::Base>,
) -> RootToken<Self>
where Self: Sized { ... }
}
Expand description
A node in a tree.
Required Associated Types§
Sourcetype Base: BaseNode
type Base: BaseNode
The ‘base node’ used in the arena.
For typed nodes where there is a typed node type in addition to separate branch and leaf
types, all of those types will use the typed node type as the ArenaNode
.
Sourcetype DataRefMut<'data>
where
Self: 'data
type DataRefMut<'data> where Self: 'data
Required Methods§
Sourcefn new(arena: &mut Arena<Self::Base>, data: Self::Data) -> Self::Tokenwhere
Self: Sized,
fn new(arena: &mut Arena<Self::Base>, data: Self::Data) -> Self::Tokenwhere
Self: Sized,
Creates a new node allocated in the given arena
using the given data
.
The node’s token is returned.
Sourcefn data_mut(&mut self) -> Self::DataRefMut<'_>
fn data_mut(&mut self) -> Self::DataRefMut<'_>
Returns a mutable reference to the data associated with this node.
Provided Methods§
Sourcefn ancestors<'node>(
&'node self,
arena: &'node Arena<Self::Base>,
) -> Ancestors<'node, Self::Base> ⓘwhere
Self: Sized,
fn ancestors<'node>(
&'node self,
arena: &'node Arena<Self::Base>,
) -> Ancestors<'node, Self::Base> ⓘwhere
Self: Sized,
Sourcefn root<'node>(&'node self, arena: &'node Arena<Self::Base>) -> RootToken<Self>where
Self: Sized,
fn root<'node>(&'node self, arena: &'node Arena<Self::Base>) -> RootToken<Self>where
Self: Sized,
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.
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> Node for SplitNode<BranchData, LeafData>
Available on crate feature split
only.
impl<BranchData, LeafData> Node for SplitNode<BranchData, LeafData>
split
only.type Base = SplitNode<BranchData, LeafData>
type Token = SplitToken<BranchData, LeafData>
type Data = SplitData<BranchData, LeafData>
type DataRef<'data> = SplitData<&'data BranchData, &'data LeafData> where Self: 'data
type DataRefMut<'data> = SplitData<&'data mut BranchData, &'data mut LeafData> where Self: 'data
Source§impl<BranchData, LeafData> Node for SplitNodeDeque<BranchData, LeafData>
Available on crate features deque
and split
only.
impl<BranchData, LeafData> Node for SplitNodeDeque<BranchData, LeafData>
deque
and split
only.type Base = SplitNodeDeque<BranchData, LeafData>
type Token = SplitTokenDeque<BranchData, LeafData>
type Data = SplitData<BranchData, LeafData>
type DataRef<'data> = SplitData<&'data BranchData, &'data LeafData> where Self: 'data
type DataRefMut<'data> = SplitData<&'data mut BranchData, &'data mut LeafData> where Self: 'data
Source§impl<BranchData, LeafData> Node for Branch<BranchData, LeafData>
Available on crate feature split
only.
impl<BranchData, LeafData> Node for Branch<BranchData, LeafData>
split
only.Source§impl<BranchData, LeafData> Node for BranchDeque<BranchData, LeafData>
Available on crate features deque
and split
only.
impl<BranchData, LeafData> Node for BranchDeque<BranchData, LeafData>
deque
and split
only.type Base = SplitNodeDeque<BranchData, LeafData>
type Token = Token<BranchDeque<BranchData, LeafData>>
type Data = BranchData
type DataRef<'data> = &'data BranchData where Self: 'data
type DataRefMut<'data> = &'data mut BranchData where Self: 'data
Source§impl<BranchData, LeafData> Node for Leaf<BranchData, LeafData>
Available on crate feature split
only.
impl<BranchData, LeafData> Node for Leaf<BranchData, LeafData>
split
only.Source§impl<BranchData, LeafData> Node for LeafDeque<BranchData, LeafData>
Available on crate features deque
and split
only.
impl<BranchData, LeafData> Node for LeafDeque<BranchData, LeafData>
deque
and split
only.type Base = SplitNodeDeque<BranchData, LeafData>
type Token = Token<LeafDeque<BranchData, LeafData>>
type Data = LeafData
type DataRef<'data> = &'data LeafData where Self: 'data
type DataRefMut<'data> = &'data mut LeafData where Self: 'data
Source§impl<Data: Debug> Node for UnifiedNode<Data>
Available on crate feature unified
only.
impl<Data: Debug> Node for UnifiedNode<Data>
unified
only.type Base = UnifiedNode<Data>
type Token = Token<UnifiedNode<Data>>
type Data = Data
type DataRef<'data> = &'data Data where Self: 'data
type DataRefMut<'data> = &'data mut Data where Self: 'data
Source§impl<Data: Debug> Node for UnifiedNodeDeque<Data>
Available on crate features deque
and unified
only.
impl<Data: Debug> Node for UnifiedNodeDeque<Data>
deque
and unified
only.