Struct stack_vm::MutableTable
[−]
[src]
pub struct MutableTable<T>(_);
A table which allows values to be overwritten. Useful for your language's local variables, etc.
use stack_vm::{MutableTable, Table}; let mut table: MutableTable<usize> = MutableTable::new(); assert!(table.is_empty()); table.insert("example", 13); assert!(!table.is_empty()); assert!(table.contains_key("example")); let value = *table.get("example").unwrap(); assert_eq!(value, 13); table.insert("example", 14); assert!(table.contains_key("example")); let value = *table.get("example").unwrap(); assert_eq!(value, 14);
Methods
impl<T> MutableTable<T>[src]
fn new() -> MutableTable<T>[src]
Return a new, empty MutableTable.
Trait Implementations
impl<T: Debug> Debug for MutableTable<T>[src]
impl<T> Table for MutableTable<T>[src]
type Item = T
The type for items stored and retrieved from the table.
fn insert(&mut self, name: &str, value: T)[src]
Insert a value into the table using a string key.
fn is_empty(&self) -> bool[src]
Is the table empty or not?
fn contains_key(&self, name: &str) -> bool[src]
Does the table contain the key or not?
fn get(&self, name: &str) -> Option<&T>[src]
Retrieve a reference to a value stored in the table by key.