Struct stack_vm::Stack
[−]
[src]
pub struct Stack<T>(_);
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]
fn new() -> Stack<T>[src]
Create a new empty Stack and return it.
fn is_empty(&self) -> bool[src]
Returns true if the stack contains no elements.
fn push(&mut self, value: T)[src]
Push an element onto the top of the stack.
fn pop(&mut self) -> T[src]
Pop the top element off the stack and return it.
fn peek(&self) -> &T[src]
Take a sneaky look at the top element on the stack.
fn peek_mut(&mut self) -> &mut T[src]
Make a sneaky change to the top element on the stack.