[][src]Enum canonical_collections::Stack

pub enum Stack<T, S: Store> {
    Empty,
    Node {
        value: T,
        prev: Repr<Self, S>,
    },
}

Proof of concept stack structure using a self-referential repr

Variants

Empty

Represents an empty stack.

Node

Non-empty top node

Fields of Node

value: T

The value on top of the stack

prev: Repr<Self, S>

A repr referencing the previous state of the stack

Implementations

impl<T, S> Stack<T, S> where
    S: Store,
    T: Canon<S> + Clone
[src]

pub fn new() -> Self[src]

Creates a new Stack

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

Pushes a value to the stack

pub fn pop(&mut self) -> Result<Option<T>, S::Error>[src]

Pops a value from the stack, if any and returns it

Trait Implementations

impl<T: Canon<S>, S: Store + Canon<S>> Canon<S> for Stack<T, S>[src]

impl<T: Clone, S: Clone + Store> Clone for Stack<T, S>[src]

impl<T: Debug, S: Debug + Store> Debug for Stack<T, S>[src]

Auto Trait Implementations

impl<T, S> Send for Stack<T, S> where
    T: Send,
    <S as Store>::Ident: Send

impl<T, S> Sync for Stack<T, S> where
    T: Sync,
    <S as Store>::Ident: Sync

impl<T, S> Unpin for Stack<T, S> where
    T: Unpin,
    <S as Store>::Ident: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.