Trait Stack

Source
pub trait Stack<A> {
    // Required methods
    fn cons(self, value: A) -> Self;
    fn head(&self) -> Result<&A, StackError>;
    fn tail(&self) -> Rc<Self>;
    fn size(&self) -> usize;
    fn update(self, index: u32, new_value: A) -> Result<Self, StackError>
       where Self: Sized;
    fn get(&self, i: u32) -> Result<&A, StackError>;
}

Required Methods§

Source

fn cons(self, value: A) -> Self

Source

fn head(&self) -> Result<&A, StackError>

Source

fn tail(&self) -> Rc<Self>

Source

fn size(&self) -> usize

Source

fn update(self, index: u32, new_value: A) -> Result<Self, StackError>
where Self: Sized,

Source

fn get(&self, i: u32) -> Result<&A, StackError>

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<A> Stack<A> for List<A>