Struct gluon_base::scoped_map::ScopedMap
source · pub struct ScopedMap<K: Eq + Hash, V> { /* private fields */ }
Expand description
A map struct which allows for the introduction of different scopes Introducing a new scope will make it possible to introduce additional variables with names already defined, shadowing the old name After exiting a scope the shadowed variable will again be re introduced
Implementations§
source§impl<K: Eq + Hash + Clone, V> ScopedMap<K, V>
impl<K: Eq + Hash + Clone, V> ScopedMap<K, V>
pub fn new() -> ScopedMap<K, V>
pub fn num_scopes(&self) -> usize
sourcepub fn enter_scope(&mut self)
pub fn enter_scope(&mut self)
Introduces a new scope
pub fn current_scope(&self) -> impl Iterator<Item = (&K, &V)>
sourcepub fn exit_scope(&mut self) -> ExitScopeIter<'_, K, V> ⓘ
pub fn exit_scope(&mut self) -> ExitScopeIter<'_, K, V> ⓘ
Exits the current scope, returning an iterator over the (key, value) pairs that are removed
When ExitScopeIter
is dropped any remaining pairs of the scope is removed as well.
sourcepub fn remove<Q>(&mut self, k: &Q) -> Option<V>
pub fn remove<Q>(&mut self, k: &Q) -> Option<V>
Removes a previously inserted value from the map.
sourcepub fn in_current_scope<Q>(&self, k: &Q) -> bool
pub fn in_current_scope<Q>(&self, k: &Q) -> bool
Returns true if the key has a value declared in the last declared scope
sourcepub fn get<'a, Q>(&'a self, k: &Q) -> Option<&'a V>
pub fn get<'a, Q>(&'a self, k: &Q) -> Option<&'a V>
Returns a reference to the last inserted value corresponding to the key
sourcepub fn get_all<'a, Q>(&'a self, k: &Q) -> Option<&'a [V]>
pub fn get_all<'a, Q>(&'a self, k: &Q) -> Option<&'a [V]>
Returns a reference to the all inserted value corresponding to the key
pub fn entry(&mut self, key: K) -> Entry<'_, K, V>
pub fn contains_key<'a, Q>(&'a self, k: &Q) -> bool
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of elements in the container. Shadowed elements are counted
sourcepub fn swap(&mut self, k: K, v: V) -> Option<V>
pub fn swap(&mut self, k: K, v: V) -> Option<V>
Swaps the value stored at key, or inserts it if it is not present
pub fn pop(&mut self, k: &K) -> Option<V>
pub fn get_mut<'a>(&'a mut self, key: &K) -> Option<&'a mut V>
pub fn insert(&mut self, k: K, v: V) -> bool
pub fn into_iter(self) -> impl Iterator<Item = (K, V)>
Trait Implementations§
source§impl<K: Eq + Hash + Clone, V> Extend<(K, V)> for ScopedMap<K, V>
impl<K: Eq + Hash + Clone, V> Extend<(K, V)> for ScopedMap<K, V>
source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = (K, V)>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = (K, V)>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)