NStack

Enum NStack 

Source
pub enum NStack<T, A> {
    Leaf([Option<T>; 4]),
    Node([Option<Annotated<Box<NStack<T, A>>, A>>; 4]),
}

Variants§

§

Leaf([Option<T>; 4])

§

Node([Option<Annotated<Box<NStack<T, A>>, A>>; 4])

Implementations§

Source§

impl<T, A> NStack<T, A>
where A: Annotation<Self> + Borrow<Cardinality>,

Source

pub fn nth(&self, index: u64) -> Option<Branch<'_, Self, A>>

Construct a Branch pointing to the nth element, if any

Source

pub fn nth_mut(&mut self, index: u64) -> Option<BranchMut<'_, Self, A>>

Construct a BranchMut pointing to the nth element, if any

Source§

impl<T, A> NStack<T, A>
where A: Annotation<NStack<T, A>>,

Source

pub fn max_key<K>(&self) -> Option<Branch<'_, Self, A>>
where T: Keyed<K>, A: Borrow<MaxKey<K>>, K: Clone + PartialOrd,

Construct a Branch pointing to the element with the largest key

Source

pub fn max_key_mut<K>(&mut self) -> Option<BranchMut<'_, Self, A>>
where T: Keyed<K>, A: Borrow<MaxKey<K>>, K: Clone + PartialOrd,

Construct a BranchMut pointing to the element with the largest key

Source§

impl<T, A> NStack<T, A>

Source

pub const fn new() -> Self

Creates a new empty NStack

Source§

impl<T, A> NStack<T, A>
where A: Annotation<Self>,

Source

pub fn push(&mut self, t: T)

Pushes a new element onto the stack

Source

pub fn pop(&mut self) -> Option<T>

Pop an element off the stack.

Returns the popped element, if any.

Trait Implementations§

Source§

impl<T, A> Annotation<NStack<T, A>> for ()

Source§

fn from_child(_: &NStack<T, A>) -> Self

Compute the annotation from the child.
Source§

impl<T> Annotation<NStack<T, Cardinality>> for Cardinality

Source§

fn from_child(stack: &NStack<T, Cardinality>) -> Self

Compute the annotation from the child.
Source§

impl<T, K> Annotation<NStack<T, MaxKey<K>>> for MaxKey<K>
where T: Keyed<K>, K: Clone + PartialOrd,

Source§

fn from_child(stack: &NStack<T, MaxKey<K>>) -> Self

Compute the annotation from the child.
Source§

impl<T, A> Clone for NStack<T, A>
where T: Clone, A: Annotation<Self>,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T, A> Compound<A> for NStack<T, A>

Source§

type Leaf = T

The leaf type of the compound collection
Source§

fn child(&self, index: usize) -> Child<'_, Self, A>

Returns a reference to a possible child at specified index
Source§

fn child_mut(&mut self, index: usize) -> ChildMut<'_, Self, A>

Returns a mutable reference to a possible child at specified index
Source§

impl<T: Debug, A: Debug> Debug for NStack<T, A>

Source§

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

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

impl<T, A> Default for NStack<T, A>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T, A> MutableLeaves for NStack<T, A>

Auto Trait Implementations§

§

impl<T, A> !Freeze for NStack<T, A>

§

impl<T, A> !RefUnwindSafe for NStack<T, A>

§

impl<T, A> Send for NStack<T, A>
where T: Send, A: Send,

§

impl<T, A> !Sync for NStack<T, A>

§

impl<T, A> Unpin for NStack<T, A>
where T: Unpin, A: Unpin,

§

impl<T, A> UnwindSafe for NStack<T, A>
where T: UnwindSafe, A: UnwindSafe,

Blanket Implementations§

Source§

impl<'a, C, A> Annotation<&'a C> for A
where A: Annotation<C>,

Source§

fn from_child(t: &&'a C) -> A

Compute the annotation from the child.
Source§

impl<'a, C, A> Annotation<&'a mut C> for A
where A: Annotation<C>,

Source§

fn from_child(t: &&'a mut C) -> A

Compute the annotation from the child.
Source§

impl<C, A> Annotation<Arc<C>> for A
where A: Annotation<C>,

Source§

fn from_child(t: &Arc<C>) -> A

Compute the annotation from the child.
Source§

impl<C, A> Annotation<Box<C>> for A
where A: Annotation<C>,

Source§

fn from_child(t: &Box<C>) -> A

Compute the annotation from the child.
Source§

impl<C, A> Annotation<Rc<C>> for A
where A: Annotation<C>,

Source§

fn from_child(t: &Rc<C>) -> A

Compute the annotation from the child.
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<C, A> First<A> for C
where C: Compound<A>, A: Annotation<C>,

Source§

fn first(&self) -> Option<Branch<'_, C, A>>

Construct a Branch pointing to the first element, if not empty
Source§

fn first_mut(&mut self) -> Option<BranchMut<'_, C, A>>
where C: MutableLeaves,

Construct a BranchMut pointing to the first element, if not empty
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<K> Keyed<K> for K

Source§

fn key(&self) -> &K

Return a reference to the key of the leaf type
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.