pub struct Stack<T: Debug + PartialEq>(pub Vec<T>);Tuple Fields§
§0: Vec<T>Implementations§
Source§impl<T: Debug + PartialEq> Stack<T>
impl<T: Debug + PartialEq> Stack<T>
Sourcepub fn push(&mut self, value: T)
pub fn push(&mut self, value: T)
This function pushes the given value on to the stack.
§Arguments
value - The value to push on to the stack.
Sourcepub fn pop(&mut self, pos: usize) -> Result<T, Error>
pub fn pop(&mut self, pos: usize) -> Result<T, Error>
This function pop the top value on to the stack. This may result in an error if the stack is empty.
§Arguments
pos - The position where the pop was called. This is used if there was error.
Sourcepub fn peek(&self) -> Option<&T>
pub fn peek(&self) -> Option<&T>
This function returns a reference to the top value on the stack, without consuming it. If the stack is empty, None is returned.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Stack<T>
impl<T> RefUnwindSafe for Stack<T>where
T: RefUnwindSafe,
impl<T> Send for Stack<T>where
T: Send,
impl<T> Sync for Stack<T>where
T: Sync,
impl<T> Unpin for Stack<T>where
T: Unpin,
impl<T> UnwindSafe for Stack<T>where
T: 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