Trait stack_trait::Stack
source · pub trait Stack {
type Item;
// Required methods
fn s_is_empty(&self) -> bool;
fn s_push(&mut self, item: Self::Item);
fn lifo_push(&mut self, item: Self::Item) -> LIFOEntry<'_, Self>;
fn s_pop(&mut self) -> Option<Self::Item>;
fn lifo_ref(&self) -> Option<&Self::Item>;
fn lifo_mut(&mut self) -> Option<&mut Self::Item>;
// Provided methods
fn s_push_checked(&mut self, item: Self::Item) -> Option<()> { ... }
unsafe fn s_pop_unchecked(&mut self) -> Self::Item { ... }
fn lifo(&mut self) -> Option<LIFOEntry<'_, Self>> { ... }
unsafe fn lifo_unchecked(&mut self) -> LIFOEntry<'_, Self> { ... }
unsafe fn lifo_ref_unchecked(&self) -> &Self::Item { ... }
unsafe fn lifo_mut_unchecked(&mut self) -> &mut Self::Item { ... }
}
Expand description
Implementors of this method can be used as a stack in DSA terms.
Required Associated Types§
Required Methods§
sourcefn s_is_empty(&self) -> bool
fn s_is_empty(&self) -> bool
Returns true
if the stack is empty.
sourcefn lifo_push(&mut self, item: Self::Item) -> LIFOEntry<'_, Self>
fn lifo_push(&mut self, item: Self::Item) -> LIFOEntry<'_, Self>
Pushes an item to the stack and returns an the “entry” object corresponding to the pushed element.
sourcefn s_pop(&mut self) -> Option<Self::Item>
fn s_pop(&mut self) -> Option<Self::Item>
sourcefn lifo_ref(&self) -> Option<&Self::Item>
fn lifo_ref(&self) -> Option<&Self::Item>
Returns a shared reference to the top element of the stack.
Also see
Provided Methods§
sourcefn s_push_checked(&mut self, item: Self::Item) -> Option<()>
fn s_push_checked(&mut self, item: Self::Item) -> Option<()>
sourceunsafe fn s_pop_unchecked(&mut self) -> Self::Item
unsafe fn s_pop_unchecked(&mut self) -> Self::Item
sourcefn lifo(&mut self) -> Option<LIFOEntry<'_, Self>>
fn lifo(&mut self) -> Option<LIFOEntry<'_, Self>>
sourceunsafe fn lifo_unchecked(&mut self) -> LIFOEntry<'_, Self>
unsafe fn lifo_unchecked(&mut self) -> LIFOEntry<'_, Self>
sourceunsafe fn lifo_ref_unchecked(&self) -> &Self::Item
unsafe fn lifo_ref_unchecked(&self) -> &Self::Item
sourceunsafe fn lifo_mut_unchecked(&mut self) -> &mut Self::Item
unsafe fn lifo_mut_unchecked(&mut self) -> &mut Self::Item
Returns a mutable reference to the top element of the stack without checking if the stack is empty.
Safety
The stack must not be empty.
Object Safety§
This trait is not object safe.