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>

source

pub fn new() -> ScopedMap<K, V>

source

pub fn num_scopes(&self) -> usize

source

pub fn enter_scope(&mut self)

Introduces a new scope

source

pub fn current_scope(&self) -> impl Iterator<Item = (&K, &V)>

source

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.

source

pub fn remove<Q>(&mut self, k: &Q) -> Option<V>
where K: Borrow<Q> + Debug, Q: ?Sized + Eq + Hash, V: Debug,

Removes a previously inserted value from the map.

source

pub fn in_current_scope<Q>(&self, k: &Q) -> bool
where K: Borrow<Q>, Q: Eq + Hash,

Returns true if the key has a value declared in the last declared scope

source

pub fn get<'a, Q>(&'a self, k: &Q) -> Option<&'a V>
where K: Borrow<Q>, Q: Eq + Hash + ?Sized,

Returns a reference to the last inserted value corresponding to the key

source

pub fn get_all<'a, Q>(&'a self, k: &Q) -> Option<&'a [V]>
where K: Borrow<Q>, Q: Eq + Hash + ?Sized,

Returns a reference to the all inserted value corresponding to the key

source

pub fn entry(&mut self, key: K) -> Entry<'_, K, V>

source

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

source

pub fn len(&self) -> usize

Returns the number of elements in the container. Shadowed elements are counted

source

pub fn is_empty(&self) -> bool

Returns true if this map is empty

source

pub fn clear(&mut self)

Removes all elements

source

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

source

pub fn pop(&mut self, k: &K) -> Option<V>

source

pub fn get_mut<'a>(&'a mut self, key: &K) -> Option<&'a mut V>

source

pub fn insert(&mut self, k: K, v: V) -> bool

source

pub fn into_iter(self) -> impl Iterator<Item = (K, V)>

source§

impl<K: Eq + Hash, V> ScopedMap<K, V>

source

pub fn iter_mut(&mut self) -> IterMut<'_, K, Vec<V>>

Returns an iterator of the (key, values) pairs inserted in the map

source

pub fn iter(&self) -> Iter<'_, K, V>

Trait Implementations§

source§

impl<K, V> Debug for ScopedMap<K, V>
where K: Eq + Hash + Debug + Clone, V: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<K: Eq + Hash, V> Default for ScopedMap<K, V>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

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)>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more

Auto Trait Implementations§

§

impl<K, V> RefUnwindSafe for ScopedMap<K, V>

§

impl<K, V> Send for ScopedMap<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for ScopedMap<K, V>
where K: Sync, V: Sync,

§

impl<K, V> Unpin for ScopedMap<K, V>
where K: Unpin, V: Unpin,

§

impl<K, V> UnwindSafe for ScopedMap<K, V>
where K: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<Id> AsId<Id> for Id
where Id: ?Sized,

source§

fn as_id(&self) -> &Id

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Any for T
where T: Any,