pub trait Stack: Debug {
type Error: Sized + 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§
Required Methods§
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.
Implementations on Foreign Types§
Source§impl Stack for Vec<State>
Available on crate feature alloc
only.An unbounded Stack
premised on the allocating Vec
.
impl Stack for Vec<State>
Available on crate feature
alloc
only.An unbounded Stack
premised on the allocating Vec
.
This SHOULD NOT be used. This allows serializations to use an unbounded amount of memory to represent objects of arbitrary depth. It’s here solely to offer ‘complete’ support for all possible serializations (compliant with RFC 8259).