pub struct HashMapRef<'map, K, V, S, G> { /* private fields */ }Expand description
A pinned reference to a HashMap.
This type is created with HashMap::pin and can be used to easily access a HashMap
without explicitly managing a guard. See the crate-level documentation for details.
Implementations§
Source§impl<'map, K, V, S, G> HashMapRef<'map, K, V, S, G>
impl<'map, K, V, S, G> HashMapRef<'map, K, V, S, G>
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of entries in the map.
See HashMap::len for details.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the map is empty. Otherwise returns false.
See HashMap::is_empty for details.
Sourcepub fn contains_key<Q>(&self, key: &Q) -> bool
pub fn contains_key<Q>(&self, key: &Q) -> bool
Returns true if the map contains a value for the specified key.
See HashMap::contains_key for details.
Sourcepub fn get<Q>(&self, key: &Q) -> Option<&V>
pub fn get<Q>(&self, key: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
See HashMap::get for details.
Sourcepub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>
pub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>
Returns the key-value pair corresponding to the supplied key.
See HashMap::get_key_value for details.
Sourcepub fn insert(&self, key: K, value: V) -> Option<&V>
pub fn insert(&self, key: K, value: V) -> Option<&V>
Inserts a key-value pair into the map.
See HashMap::insert for details.
Sourcepub fn try_insert(&self, key: K, value: V) -> Result<&V, OccupiedError<'_, V>>
pub fn try_insert(&self, key: K, value: V) -> Result<&V, OccupiedError<'_, V>>
Tries to insert a key-value pair into the map, and returns a reference to the value that was inserted.
See HashMap::try_insert for details.
Sourcepub fn try_insert_with<F>(&self, key: K, f: F) -> Result<&V, &V>where
F: FnOnce() -> V,
pub fn try_insert_with<F>(&self, key: K, f: F) -> Result<&V, &V>where
F: FnOnce() -> V,
Tries to insert a key and value computed from a closure into the map, and returns a reference to the value that was inserted.
See HashMap::try_insert_with for details.
Sourcepub fn get_or_insert(&self, key: K, value: V) -> &V
pub fn get_or_insert(&self, key: K, value: V) -> &V
Returns a reference to the value corresponding to the key, or inserts a default value.
See HashMap::get_or_insert for details.
Sourcepub fn get_or_insert_with<F>(&self, key: K, f: F) -> &Vwhere
F: FnOnce() -> V,
pub fn get_or_insert_with<F>(&self, key: K, f: F) -> &Vwhere
F: FnOnce() -> V,
Returns a reference to the value corresponding to the key, or inserts a default value computed from a closure.
See HashMap::get_or_insert_with for details.
Sourcepub fn update<F>(&self, key: K, update: F) -> Option<&V>
pub fn update<F>(&self, key: K, update: F) -> Option<&V>
Updates an existing entry atomically.
See HashMap::update for details.
Sourcepub fn update_or_insert<F>(&self, key: K, update: F, value: V) -> &V
pub fn update_or_insert<F>(&self, key: K, update: F, value: V) -> &V
Updates an existing entry or inserts a default value.
See HashMap::update_or_insert for details.
Sourcepub fn update_or_insert_with<U, F>(&self, key: K, update: U, f: F) -> &V
pub fn update_or_insert_with<U, F>(&self, key: K, update: U, f: F) -> &V
Updates an existing entry or inserts a default value computed from a closure.
See HashMap::update_or_insert_with for details.
Sourcepub fn compute<'g, F, T>(&'g self, key: K, compute: F) -> Compute<'g, K, V, T>
pub fn compute<'g, F, T>(&'g self, key: K, compute: F) -> Compute<'g, K, V, T>
See HashMap::compute for details.
Sourcepub fn remove<Q>(&self, key: &Q) -> Option<&V>
pub fn remove<Q>(&self, key: &Q) -> Option<&V>
Removes a key from the map, returning the value at the key if the key was previously in the map.
See HashMap::remove for details.
Sourcepub fn remove_entry<Q>(&self, key: &Q) -> Option<(&K, &V)>
pub fn remove_entry<Q>(&self, key: &Q) -> Option<(&K, &V)>
Removes a key from the map, returning the stored key and value if the key was previously in the map.
See HashMap::remove_entry for details.
Sourcepub fn remove_if<Q, F>(
&self,
key: &Q,
should_remove: F,
) -> Result<Option<(&K, &V)>, (&K, &V)>
pub fn remove_if<Q, F>( &self, key: &Q, should_remove: F, ) -> Result<Option<(&K, &V)>, (&K, &V)>
Conditionally removes a key from the map based on the provided closure.
See HashMap::remove_if for details.
Sourcepub fn clear(&self)
pub fn clear(&self)
Clears the map, removing all key-value pairs.
See HashMap::clear for details.
Sourcepub fn retain<F>(&mut self, f: F)
pub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
See HashMap::retain for details.
Sourcepub fn reserve(&self, additional: usize)
pub fn reserve(&self, additional: usize)
Tries to reserve capacity for additional more elements to be inserted
in the map.
See HashMap::reserve for details.
Sourcepub fn iter(&self) -> Iter<'_, K, V, G> ⓘ
pub fn iter(&self) -> Iter<'_, K, V, G> ⓘ
An iterator visiting all key-value pairs in arbitrary order.
The iterator element type is (&K, &V).
See HashMap::iter for details.
Sourcepub fn keys(&self) -> Keys<'_, K, V, G> ⓘ
pub fn keys(&self) -> Keys<'_, K, V, G> ⓘ
An iterator visiting all keys in arbitrary order.
The iterator element type is &K.
See HashMap::keys for details.
Sourcepub fn values(&self) -> Values<'_, K, V, G> ⓘ
pub fn values(&self) -> Values<'_, K, V, G> ⓘ
An iterator visiting all values in arbitrary order.
The iterator element type is &V.
See HashMap::values for details.