pub struct EnvMap<K, V> { /* private fields */ }Expand description
EnvMap is a wrapper of HashMap, but with the ability to backtrack and recover from modification
Implementations§
Source§impl<K, V> EnvMap<K, V>
impl<K, V> EnvMap<K, V>
Sourcepub fn with_capacity(capacity: usize) -> EnvMap<K, V>
pub fn with_capacity(capacity: usize) -> EnvMap<K, V>
Creating an empty EnvMap with capacity
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
Sourcepub fn iter(&self) -> Iter<'_, K, V>
pub fn iter(&self) -> Iter<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order.
Sourcepub fn is_scope_empty(&self) -> bool
pub fn is_scope_empty(&self) -> bool
Returns true if there is no saved scope frame
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the map, removing all key-value pairs. Keeps the allocated memory for reuse.
Sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
pub fn get<Q>(&self, k: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
Sourcepub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
pub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
Returns the key-value pair corresponding to the supplied key.
Sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
pub fn contains_key<Q>(&self, k: &Q) -> bool
Returns true if the map contains a value for the specified key.
Sourcepub fn enter_scope(&mut self)
pub fn enter_scope(&mut self)
Enter a new scope, record the current pivot of history
Sourcepub fn leave_scope(&mut self)
pub fn leave_scope(&mut self)
Leave from a scope, unwind the history and recover.
Trait Implementations§
Auto Trait Implementations§
impl<K, V> Freeze for EnvMap<K, V>
impl<K, V> RefUnwindSafe for EnvMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for EnvMap<K, V>
impl<K, V> Sync for EnvMap<K, V>
impl<K, V> Unpin for EnvMap<K, V>
impl<K, V> UnsafeUnpin for EnvMap<K, V>
impl<K, V> UnwindSafe for EnvMap<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<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