Stack

Trait Stack 

Source
pub trait Stack: Debug {
    type Error: Copy + Debug;

    // Required methods
    fn empty() -> Self;
    fn depth(&self) -> usize;
    fn peek(&self) -> Option<State>;
    fn pop(&mut self) -> Option<State>;
    fn push(&mut self, item: State) -> Result<(), Self::Error>;
}
Expand description

A trait representing a stack.

Required Associated Types§

Source

type Error: Copy + Debug

This stack’s error type.

Required Methods§

Source

fn empty() -> Self

Create an empty stack.

Source

fn depth(&self) -> usize

The current stack depth.

Source

fn peek(&self) -> Option<State>

Peek at the current item on the stack.

Source

fn pop(&mut self) -> Option<State>

Pop the next item from the stack.

Source

fn push(&mut self, item: State) -> Result<(), Self::Error>

Push an item onto the stack.

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<const ONE_FOURTH_OF_MAX_DEPTH: usize> Stack for ConstStack<ONE_FOURTH_OF_MAX_DEPTH>

Source§

type Error = StackError