pub trait SymbolMap<K> {
type Value;
// Required methods
fn insert(&mut self, key: K, value: Self::Value);
fn get<Q>(&self, key: &Q) -> Option<&Self::Value>
where Q: ?Sized + Hash + Eq,
K: Borrow<Q>;
fn is_empty(&self) -> bool;
fn try_get_mut<Q>(&mut self, key: &Q) -> Option<&mut Self::Value>
where Q: ?Sized + Hash + Eq,
K: Borrow<Q>;
fn push(&mut self);
fn pop(&mut self);
fn depth(&self) -> usize;
// Provided method
fn contains_key<Q>(&self, key: &Q) -> bool
where Q: ?Sized + Hash + Eq,
K: Borrow<Q> { ... }
}Expand description
A trait for a symbol table which can be indexed by a given key.
Behaves like a stack of HashMaps.
Required Associated Types§
Required Methods§
Sourcefn insert(&mut self, key: K, value: Self::Value)
fn insert(&mut self, key: K, value: Self::Value)
Insert a key/value pair into this symbol table at the current level
Sourcefn get<Q>(&self, key: &Q) -> Option<&Self::Value>
fn get<Q>(&self, key: &Q) -> Option<&Self::Value>
Get the most recent definition of a key in this symbol table
Sourcefn try_get_mut<Q>(&mut self, key: &Q) -> Option<&mut Self::Value>
fn try_get_mut<Q>(&mut self, key: &Q) -> Option<&mut Self::Value>
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.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.