[][src]Enum canonical_collections::Stack

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

Proof of concept stack structure using a self-referential repr



Represents an empty stack.


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


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

pub fn new() -> Self[src]

Creates a new Stack

pub fn push(&mut self, t: T) -> Result<(), S::Error>[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

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

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

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

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.