Struct stack_vm::WriteOnceTable
[−]
[src]
pub struct WriteOnceTable<T>(_);
A table which does not allow values to be overwritten. Useful for your languages constants, etc.
use stack_vm::{WriteOnceTable, Table}; let mut table: WriteOnceTable<usize> = WriteOnceTable::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);
use stack_vm::{WriteOnceTable, Table}; let mut table: WriteOnceTable<usize> = WriteOnceTable::new(); table.insert("example", 13); table.insert("example", 14);
Methods
impl<T> WriteOnceTable<T>
[src]
fn new() -> WriteOnceTable<T>
[src]
Return a new, empty WriteOnceTable
.
fn keys(&self) -> Vec<&String>
[src]
Trait Implementations
impl<T: Debug> Debug for WriteOnceTable<T>
[src]
impl<T> Table for WriteOnceTable<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.