pub struct SymbolTable<K: Hash + Eq, V> { /* private fields */ }
Expand description
A simple, generic symbol table
Implementations§
Source§impl<K: Hash + Eq, V> SymbolTable<K, V>
impl<K: Hash + Eq, V> SymbolTable<K, V>
Sourcepub fn new() -> SymbolTable<K, V>
pub fn new() -> SymbolTable<K, V>
Create a new, empty symbol table
Sourcepub fn with_capacity(n: usize) -> SymbolTable<K, V>
pub fn with_capacity(n: usize) -> SymbolTable<K, V>
Create a symbol table with a given capacity
Sourcepub fn def(&mut self, key: K, value: V) -> Option<V>
pub fn def(&mut self, key: K, value: V) -> Option<V>
Register a given symbol at the current depth, returning the current definition at the current depth, if any.
Sourcepub fn get_full<Q>(&self, key: &Q) -> Option<(&V, usize)>
pub fn get_full<Q>(&self, key: &Q) -> Option<(&V, usize)>
Get the definition of a current symbol, along with its depth, if any
Sourcepub fn get_full_mut<Q>(&mut self, key: &Q) -> Option<(&mut V, usize)>
pub fn get_full_mut<Q>(&mut self, key: &Q) -> Option<(&mut V, usize)>
Mutably get the definition of a current symbol, along with its depth, if any
Sourcepub fn try_get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
pub fn try_get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
Try to mutably get the definition of a current symbol at the current depth
Sourcepub fn jump_to_depth(&mut self, depth: usize)
pub fn jump_to_depth(&mut self, depth: usize)
Get the mutable definition of a current symbol, along with its depth, if any Jump to a given depth, removing obsolete definitions. Return the number of keys and definitions removed, as well as keys touched, if any.
Trait Implementations§
Source§impl<K: Clone + Hash + Eq, V: Clone> Clone for SymbolTable<K, V>
impl<K: Clone + Hash + Eq, V: Clone> Clone for SymbolTable<K, V>
Source§fn clone(&self) -> SymbolTable<K, V>
fn clone(&self) -> SymbolTable<K, V>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreimpl<K: Eq + Hash + Eq, V: Eq> Eq for SymbolTable<K, V>
impl<K: Hash + Eq, V> StructuralPartialEq for SymbolTable<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for SymbolTable<K, V>
impl<K, V> RefUnwindSafe for SymbolTable<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for SymbolTable<K, V>
impl<K, V> Sync for SymbolTable<K, V>
impl<K, V> Unpin for SymbolTable<K, V>
impl<K, V> UnwindSafe for SymbolTable<K, V>where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more