pub struct Environment<K: Hash + Eq, V: PartialEq> { /* private fields */ }Expand description
An environment as a linked-list of hashmaps.
Each node of the linked-list corresponds to what is called “a layer”, where only the current layer can be modified, the previous ones are only accessible for lookup.
For the generic parameters, K is the type for the environment
keys, and V are their value.
The linked list is composed of the current layer and the previous layers.
The current layer is stored as an Rc<Hashmap>.
Insertions are made by “split-on-write”: if the current layer has no other references, it is mutated. If it has other references, the current layer is pushed down as the new “previous” layer, and a new layer is started.
Implementations§
Source§impl<K: Hash + Eq, V: PartialEq> Environment<K, V>
impl<K: Hash + Eq, V: PartialEq> Environment<K, V>
Sourcepub fn iter_layers(&self) -> EnvLayerIter<'_, K, V> ⓘ
pub fn iter_layers(&self) -> EnvLayerIter<'_, K, V> ⓘ
Creates an iterator that visits all layers from the most recent one to the oldest.
The element iterator type is Rc<HashMap<K, V>>.
Sourcepub fn iter_elems(&self) -> impl Iterator<Item = (&K, &V)>
pub fn iter_elems(&self) -> impl Iterator<Item = (&K, &V)>
Creates an iterator that visits all elements from the Environment, from the oldest layer to
the most recent one. It uses this order, so calling collect on this iterator to create a
hashmap would have the same values as the Environment. The element iterator type is (&'env K, &'env V), with 'env being the lifetime of the Environment.
Trait Implementations§
Source§impl<K: Hash + Eq, V: PartialEq> Extend<(K, V)> for Environment<K, V>
impl<K: Hash + Eq, V: PartialEq> Extend<(K, V)> for Environment<K, V>
Source§fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
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)Source§impl<K: Hash + Eq, V: PartialEq> FromIterator<(K, V)> for Environment<K, V>
impl<K: Hash + Eq, V: PartialEq> FromIterator<(K, V)> for Environment<K, V>
impl<K: Hash + Eq, V: PartialEq> StructuralPartialEq for Environment<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for Environment<K, V>
impl<K, V> RefUnwindSafe for Environment<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> !Send for Environment<K, V>
impl<K, V> !Sync for Environment<K, V>
impl<K, V> Unpin for Environment<K, V>
impl<K, V> UnsafeUnpin for Environment<K, V>
impl<K, V> UnwindSafe for Environment<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
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
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>
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>
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