[−][src]Struct stack_vm::Stack
A stack.
Supports only the most basic stack operations needed for the machine.
Implemending using a Vec
.
use stack_vm::Stack; let mut stack: Stack<usize> = Stack::new(); assert!(stack.is_empty()); stack.push(13); assert!(!stack.is_empty()); let value = stack.pop(); assert_eq!(value, 13);
Methods
impl<T: Debug> Stack<T>
[src]
pub fn new() -> Stack<T>
[src]
Create a new empty Stack
and return it.
pub fn is_empty(&self) -> bool
[src]
Returns true
if the stack contains no elements.
pub fn push(&mut self, value: T)
[src]
Push an element onto the top of the stack.
pub fn pop(&mut self) -> T
[src]
Pop the top element off the stack and return it.
pub fn peek(&self) -> &T
[src]
Take a sneaky look at the top element on the stack.
pub fn peek_mut(&mut self) -> &mut T
[src]
Make a sneaky change to the top element on the stack.
pub fn as_slice(&self) -> &[T]
[src]
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,