Struct stack_vm::WriteManyTable
[−]
[src]
pub struct WriteManyTable<T>(_);
A table which allows values to be overwritten. Useful for your language's local variables, etc.
use stack_vm::{WriteManyTable, Table}; let mut table: WriteManyTable<usize> = WriteManyTable::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> WriteManyTable<T>
[src]
fn new() -> WriteManyTable<T>
[src]
Return a new, empty WriteManyTable
.
Trait Implementations
impl<T: Debug> Debug for WriteManyTable<T>
[src]
impl<T> Table for WriteManyTable<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.