Skip to main content

PersistentScopedMap

Struct PersistentScopedMap 

Source
pub struct PersistentScopedMap<K, V> { /* private fields */ }
Expand description

Scoped hash table similar to hermes::ScopedHashTable, but scopes can be retained and reactivated after they have been popped from the table. See the module documentation for the full example and for the deviations from the C++ implementation.

Implementations§

Source§

impl<K: Eq + Hash + Copy, V: Clone> PersistentScopedMap<K, V>

Source

pub fn new() -> Self

Source

pub fn current_scope(&self) -> ScopePtr<K, V>

Return a pointer to the current scope. The pointer may be null.

Source

pub fn try_emplace_into_scope( &self, scope: &ScopePtr<K, V>, key: K, value: V, ) -> bool

Attempt to insert an element into the specified scope. Returns whether the insertion took place (false if key already has a binding in scope). A key may not be inserted such that it would be shadowed by another scope currently in effect. Attempting to do so results in undefined behavior.

Source

pub fn try_emplace(&self, key: K, value: V) -> bool

Attempt to insert an element into the current scope. Returns whether the insertion took place.

Source

pub fn put_in_scope(&self, scope: &ScopePtr<K, V>, key: K, value: V)

Insert or update a value in the specified scope. A key may not be inserted such that it would be shadowed by another scope currently in effect. Attempting to do so results in undefined behavior.

Source

pub fn put(&self, key: K, value: V)

Insert or update an existing value in the current scope.

Source

pub fn count(&self, key: &K) -> u32

Returns 1 if the value is defined, 0 if it’s not.

Source

pub fn lookup(&self, key: &K) -> Option<V>

Gets the innermost value for a key, or None if none.

Source

pub fn find(&self, key: &K) -> Option<V>

Return the innermost value for a key, or None if none.

Source

pub fn find_with_depth(&self, key: &K) -> Option<(V, u32)>

\return the innermost value for a key along with its depth, or None if none.

Source

pub fn find_in_current_scope(&self, key: &K) -> Option<V>

\return the value for a key if it exists in the current scope, or None if none.

Source

pub fn activate_scope(&self, new_scope_ptr: &ScopePtr<K, V>)

Source

pub fn flatten(&self) -> HashMap<K, V>

Gets all values currently in scope. Port of the UNIT_TEST-only test_flatten; kept pub (not test-gated) since the resolver’s own tests use it too.

Source

pub fn keys_by_scope(&self) -> Vec<Vec<K>>

Gets keys in each scope. This may correspond to a ScopeChain. Shadowed keys are ignored. Index 0 is innermost. Port of the UNIT_TEST-only test_getKeysByScope; kept pub for the same reason as flatten.

Trait Implementations§

Source§

impl<K: Eq + Hash + Copy, V: Clone> Default for PersistentScopedMap<K, V>

Source§

fn default() -> Self

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

impl<K, V> Drop for PersistentScopedMap<K, V>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<K, V> !Freeze for PersistentScopedMap<K, V>

§

impl<K, V> !RefUnwindSafe for PersistentScopedMap<K, V>

§

impl<K, V> !Send for PersistentScopedMap<K, V>

§

impl<K, V> !Sync for PersistentScopedMap<K, V>

§

impl<K, V> !UnwindSafe for PersistentScopedMap<K, V>

§

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

§

impl<K, V> UnsafeUnpin for PersistentScopedMap<K, V>

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

Source§

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

Source§

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.