[][src]Trait hayami_im::SymbolMap

pub trait SymbolMap<K> {
    type Value;
    fn insert(&mut self, key: K, value: Self::Value);
fn get<Q>(&self, key: &Q) -> Option<&Self::Value>
    where
        K: Borrow<Q>,
        Q: Hash + Eq + ?Sized
;
fn is_empty(&self) -> bool;
fn try_get_mut<Q>(&mut self, key: &Q) -> Option<&mut Self::Value>
    where
        K: Borrow<Q>,
        Q: Hash + Eq + ?Sized
;
fn push(&mut self);
fn pop(&mut self);
fn depth(&self) -> usize; fn contains_key<Q>(&self, key: &Q) -> bool
    where
        K: Borrow<Q>,
        Q: Hash + Eq + ?Sized
, { ... } }

A trait for a symbol table which can be indexed by a given key.

Behaves like a stack of HashMaps.

Associated Types

type Value

The value stored in this symbol table

Loading content...

Required methods

fn insert(&mut self, key: K, value: Self::Value)

Insert a key/value pair into this symbol table at the current level

fn get<Q>(&self, key: &Q) -> Option<&Self::Value> where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized

Get the most recent definition of a key in this symbol table

fn is_empty(&self) -> bool

Whether this symbol table is empty

fn try_get_mut<Q>(&mut self, key: &Q) -> Option<&mut Self::Value> where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized

Try to get a mutable reference to the definition of a key in the top level of this symbol table

May fail for arbitrary reasons, to avoid, e.g., re-inserting the key at the top level as mutable.

fn push(&mut self)

Push a level onto this symbol table

fn pop(&mut self)

Pop a level from this symbol table

Note that this is not guaranteed to drop all elements stored in the level!

fn depth(&self) -> usize

Get the current depth of this symbol table

Loading content...

Provided methods

fn contains_key<Q>(&self, key: &Q) -> bool where
    K: Borrow<Q>,
    Q: Hash + Eq + ?Sized

Whether this symbol table contains this key

Loading content...

Implementors

impl<K: Hash + Eq + Clone, V: Clone, S: BuildHasher> SymbolMap<K> for SymbolTable<K, V, S>[src]

type Value = V

Loading content...