pub struct Stack<Val = Value>where
Val: Debug,{ /* private fields */ }
Expand description
An ordered sequence of values that can be operated in a LIFO-alike way.
Every Stack
actually comprises two sequences of values: the main
sub-stack and the alt
sub-stack.
As its name indicates, the main
sub-stack is the one you operate by default.
That is, the alt
sub-stack cannot be operated directly — you can only move values between both sub-stacks with the pop_into_alt
and push_from_alt
methods.
The alt
sub-stack is therefore limited for usage as a sort of clipboard for values.
Implementations§
Source§impl<Val> Stack<Val>where
Val: Debug,
impl<Val> Stack<Val>where
Val: Debug,
Sourcepub fn length(&self) -> usize
pub fn length(&self) -> usize
Returns the number of values in the main
sub-stack, also referred to as its ‘length’.
§Examples
Sourcepub fn pop(&mut self) -> Option<Val>
pub fn pop(&mut self) -> Option<Val>
Removes the topmost value in the main
sub-stack and returns it.
§Examples
Sourcepub fn pop_into_alt(&mut self)
pub fn pop_into_alt(&mut self)
Sourcepub fn push_from_alt(&mut self)
pub fn push_from_alt(&mut self)
Similar to push
, but instead of receiving the value to be pushed as an argument, it pops it from the alt
sub-stack.
Trait Implementations§
Auto Trait Implementations§
impl<Val> Freeze for Stack<Val>
impl<Val> RefUnwindSafe for Stack<Val>where
Val: RefUnwindSafe,
impl<Val> Send for Stack<Val>where
Val: Send,
impl<Val> Sync for Stack<Val>where
Val: Sync,
impl<Val> Unpin for Stack<Val>where
Val: Unpin,
impl<Val> UnwindSafe for Stack<Val>where
Val: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more