[][src]Trait wasmer_interface_types::interpreter::stack::Stackable

pub trait Stackable {
    type Item;
    fn is_empty(&self) -> bool;
fn as_slice(&self) -> &[Self::Item];
fn push(&mut self, item: Self::Item);
fn pop1(&mut self) -> Option<Self::Item>;
fn pop(&mut self, n: usize) -> Option<Vec<Self::Item>>;
fn peek1(&self) -> Option<&Self::Item>; }

The Stackable trait represents a small basic set of operations required by the interpreter.

Associated Types

type Item

The kind of item the stack holds.

Loading content...

Required methods

fn is_empty(&self) -> bool

Checks whether the stack is empty.

fn as_slice(&self) -> &[Self::Item]

Extracts a slice containing the entire stack.

fn push(&mut self, item: Self::Item)

Appends one item to the end of the stack.

fn pop1(&mut self) -> Option<Self::Item>

Removes the last item of the stack and returns it, None if the stack is empty.

fn pop(&mut self, n: usize) -> Option<Vec<Self::Item>>

Removes n elements from the end of the stack, None if the stack doesn't contain enough elements. Returned items are in reverse order: the last element comes last in the list.

fn peek1(&self) -> Option<&Self::Item>

Peek the last item of the stack and returns a reference to it, None if the stack is empty.

Loading content...

Implementors

impl<T> Stackable for Stack<T> where
    T: Default + Clone
[src]

type Item = T

Loading content...