[][src]Struct stack_vm::Stack

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]

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

impl<T: Default> Default for Stack<T>[src]

impl<T: Debug> Debug for Stack<T>[src]

Auto Trait Implementations

impl<T> Send for Stack<T> where
    T: Send

impl<T> Sync for Stack<T> where
    T: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]