pub struct ScopeMap<K, V, S: BuildHasher = RandomState> { /* private fields */ }
Expand description

A layered hash map for representing scoped variables and their values.

Implementations

Creates an empty ScopeMap with a default hasher and capacity.

Creates an empty ScopeMap with a default hasher and the specified capacity.

Creates an empty ScopeMap with the specified hasher and a default capacity.

Creates an empty ScopeMap with the specified hasher and capacity.

Gets the number of elements the map can hold without reallocating.

Returns true if the map is empty.

Gets the number of unique keys in the map.

Gets the number of layers in the map.

Adds a new, empty layer.

Computes in O(1) time.

Removes the topmost layer (if it isn’t the bottom layer) and all associated keys/values. Returns true if a layer was removed.

Computes in O(n) time in relation to the number of keys stored in the removed layer.

Returns true if the map contains the specified key in any layer.

Computes in O(1) time.

Returns true if the map contains the specified key at the top layer.

Computes in O(1) time.

Gets a reference to the topmost value associated with a key.

Computes in O(1) time.

Gets an iterator over references to all the values associated with a key, starting with the topmost and going down.

Computes in O(1) time.

Gets a mutable reference to the topmost value associated with a key.

Computes in O(1) time.

Gets an iterator over mutable references to all the values associated with a key, starting with the topmost and going down.

Computes in O(1) time.

Gets a reference to a value min_depth layers below the topmost value associated with a key. Saturates to base layer.

Computes in O(n) time (worst-case) in relation to min_depth.

Gets a reference to the value associated with a key at least min_depth layers below the topmost layer, as well as its associated depth. Saturates to base layer.

Computes in O(n) time (worst-case) in relation to min_depth.

Gets a reference to the value associated with a key at least min_depth layers below the topmost layer, as well as its associated height. Saturates to base layer.

Computes in O(n) time (worst-case) in relation to min_depth.

Gets an iterator over references to all values min_depth layers below the topmost value associated with a key. Saturates to base layer.

Computes in O(n) time (worst-case) in relation to min_depth.

Gets a mutable reference to a value min_depth layers below the topmost value associated with a key. Saturates to base layer.

Computes in O(n) time (worst-case) in relation to min_depth.

Gets an iterator over mutable references to all values min_depth layers below the topmost value associated with a key. Saturates to base layer.

Computes in O(n) time (worst-case) in relation to min_depth.

Gets the depth of the specified key (i.e. how many layers down from the top that the key first appears). A depth of 0 refers to the top layer.

Returns None if the key does not exist.

Computes in O(n) time (worst-case) in relation to layer count.

Gets the height of the specified key (i.e. how many layers up from the bottom that the key last appears). A height of 0 refers to the bottom layer.

Returns None if the key does not exist.

Computes in O(n) time (worst-case) in relation to layer count.

Adds the specified entry to the topmost layer.

Adds the specified entry in the layer min_depth layers from the top. Saturates to base layer.

Removes the entry with the specified key from the topmost layer and returns its value.

Removes all entries in the topmost layer.

Removes all elements and additional layers.

Iterates over all key-value pairs in arbitrary order.

The iterator element type is (&'a K, &'a V).

Iterates over all key-value pairs in the topmost layer in arbitrary order.

The iterator element type is (&'a K, &'a V).

Iterates over all key-value pairs in arbitrary order, allowing mutation of the values.

The iterator element type is (&'a K, &'a mut V).

Iterates over all keys in arbitrary order.

The iterator element type is &'a K.

Iterates over all keys in the topmost layer in arbitrary order.

The iterator element type is &'a K.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Creates a new ScopeMap with the default configuration.

Returns a reference to the value associated with the provided key.

Panics

Panics if the key does not exist in the ScopeMap.

The returned type after indexing.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.