Enum SplitNode

Source
pub enum SplitNode<BranchData: Debug, LeafData: Debug> {
    Branch(Branch<BranchData, LeafData>),
    Leaf(Leaf<BranchData, LeafData>),
}
Available on crate feature split only.
Expand description

A node that is split into separate branch and leaf nodes. This is the non-deque version, where children are represented as a linked list. In this version, a node’s previous sibling(s) and next sibling(s) are available, but branches cannot be directly indexed, nor can children be detached, [removed], or inserted by index.

BranchData represents the custom data associated with branches, while LeafData represents the custom data associated with leaves.

§See also

For the deque version, see SplitNodeDeque.

For a node that isn’t split into separate branch and leaf nodes, see UnifiedNode and UnifiedNodeDeque.

Variants§

§

Branch(Branch<BranchData, LeafData>)

A branch node that may have children.

§

Leaf(Leaf<BranchData, LeafData>)

A leaf node that may not have children.

Trait Implementations§

Source§

impl<BranchData, LeafData> BaseNode for SplitNode<BranchData, LeafData>
where BranchData: Debug, LeafData: Debug,

Source§

type Representation = SplitNodeRepresentation<BranchData, LeafData>

The representation of the node after it is removed from the arena. Read more
Source§

type Branch = Branch<BranchData, LeafData>

The type used for branch nodes. Read more
Source§

type Leaf = Leaf<BranchData, LeafData>

The type used for leaf nodes. Read more
Source§

fn into_representation( self, arena: &mut Arena<Self::Base>, ) -> Self::Representation

Converts this node into its representation. Read more
Source§

impl<BranchData: Debug + Debug, LeafData: Debug + Debug> Debug for SplitNode<BranchData, LeafData>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<BranchData, LeafData> LinkedNode for SplitNode<BranchData, LeafData>
where BranchData: Debug, LeafData: Debug,

Source§

fn prev(&self) -> Option<Self::Token>

Returns the token of this node’s previous sibling. Read more
Source§

fn next(&self) -> Option<Self::Token>

Returns the token of this node’s next sibling. Read more
Source§

fn preceding_siblings<'node>( &'node self, arena: &'node Arena<Self::Base>, ) -> PrecedingSiblings<'node, Self>
where Self: Sized,

Returns an iterator over the tokens of this node’s preceding siblings. Read more
Source§

fn following_siblings<'node>( &'node self, arena: &'node Arena<Self::Base>, ) -> FollowingSiblings<'node, Self>
where Self: Sized,

Returns an iterator over the tokens of this node’s following siblings. Read more
Source§

impl<BranchData, LeafData> Node for SplitNode<BranchData, LeafData>
where BranchData: Debug, LeafData: Debug,

Source§

type Base = SplitNode<BranchData, LeafData>

The ‘base node’ used in the arena. Read more
Source§

type Token = SplitToken<BranchData, LeafData>

The token associated with this type of node.
Source§

type Data = SplitData<BranchData, LeafData>

The custom data associated with this node.
Source§

type DataRef<'data> = SplitData<&'data BranchData, &'data LeafData> where Self: 'data

A type acting as a reference to the node’s data. Read more
Source§

type DataRefMut<'data> = SplitData<&'data mut BranchData, &'data mut LeafData> where Self: 'data

A type acting as a mutable reference to the node’s data. Read more
Source§

fn new(arena: &mut Arena<Self>, data: Self::Data) -> Self::Token

Creates a new node allocated in the given arena using the given data. Read more
Source§

fn token(&self) -> Self::Token

Returns this node’s token.
Source§

fn parent(&self) -> Option<Token<<Self as BaseNode>::Branch>>

Returns the token of this node’s parent. Read more
Source§

fn data(&self) -> Self::DataRef<'_>

Returns a reference to the data associated with this node.
Source§

fn data_mut(&mut self) -> Self::DataRefMut<'_>

Returns a mutable reference to the data associated with this node.
Source§

fn ancestors<'node>( &'node self, arena: &'node Arena<Self::Base>, ) -> Ancestors<'node, Self::Base>
where Self: Sized,

Returns an iterator over the tokens of this node’s ancestors. Read more
Source§

fn root<'node>(&'node self, arena: &'node Arena<Self::Base>) -> RootToken<Self>
where Self: Sized,

Returns this node’s root node. Read more
Source§

impl<BranchData, LeafData> NodeToken<SplitNode<BranchData, LeafData>> for SplitToken<BranchData, LeafData>
where BranchData: Debug, LeafData: Debug,

Source§

fn parent( &self, arena: &Arena<N::Base>, ) -> Option<<<N::Base as BaseNode>::Branch as Node>::Token>

Returns this node’s parent’s token. Read more
Source§

fn ancestors<'arena>( &self, arena: &'arena Arena<N::Base>, ) -> Ancestors<'arena, N::Base>

Returns an iterator over the tokens of this node’s ancestors. Read more
Source§

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,

Returns this node’s root node. Read more
Source§

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,

Returns a reference to the data associated with this node.
Source§

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,

Returns a mutable reference to the data associated with this node.
Source§

fn prev(&self, arena: &Arena<N::Base>) -> Option<<N::Base as Node>::Token>
where N::Base: LinkedNode,

Returns the token of this node’s previous sibling. Read more
Source§

fn next(&self, arena: &Arena<N::Base>) -> Option<<N::Base as Node>::Token>
where N::Base: LinkedNode,

Returns the token of this node’s next sibling. Read more
Source§

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. Read more
Source§

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. Read more
Source§

impl<'node, BranchData, LeafData> TryFrom<&'node SplitNode<BranchData, LeafData>> for &'node Branch<BranchData, LeafData>
where BranchData: Debug, LeafData: Debug,

Source§

type Error = &'node SplitNode<BranchData, LeafData>

The type returned in the event of a conversion error.
Source§

fn try_from( node: &'node SplitNode<BranchData, LeafData>, ) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'node, BranchData, LeafData> TryFrom<&'node SplitNode<BranchData, LeafData>> for &'node Leaf<BranchData, LeafData>
where BranchData: Debug, LeafData: Debug,

Source§

type Error = &'node SplitNode<BranchData, LeafData>

The type returned in the event of a conversion error.
Source§

fn try_from( node: &'node SplitNode<BranchData, LeafData>, ) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'node, BranchData, LeafData> TryFrom<&'node mut SplitNode<BranchData, LeafData>> for &'node mut Branch<BranchData, LeafData>
where BranchData: Debug, LeafData: Debug,

Source§

type Error = &'node mut SplitNode<BranchData, LeafData>

The type returned in the event of a conversion error.
Source§

fn try_from( node: &'node mut SplitNode<BranchData, LeafData>, ) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'node, BranchData, LeafData> TryFrom<&'node mut SplitNode<BranchData, LeafData>> for &'node mut Leaf<BranchData, LeafData>
where BranchData: Debug, LeafData: Debug,

Source§

type Error = &'node mut SplitNode<BranchData, LeafData>

The type returned in the event of a conversion error.
Source§

fn try_from( node: &'node mut SplitNode<BranchData, LeafData>, ) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<BranchData, LeafData> Freeze for SplitNode<BranchData, LeafData>
where BranchData: Freeze, LeafData: Freeze,

§

impl<BranchData, LeafData> RefUnwindSafe for SplitNode<BranchData, LeafData>
where BranchData: RefUnwindSafe, LeafData: RefUnwindSafe,

§

impl<BranchData, LeafData> Send for SplitNode<BranchData, LeafData>
where BranchData: Send, LeafData: Send,

§

impl<BranchData, LeafData> Sync for SplitNode<BranchData, LeafData>
where BranchData: Sync, LeafData: Sync,

§

impl<BranchData, LeafData> Unpin for SplitNode<BranchData, LeafData>
where BranchData: Unpin, LeafData: Unpin,

§

impl<BranchData, LeafData> UnwindSafe for SplitNode<BranchData, LeafData>
where BranchData: UnwindSafe, LeafData: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.