Struct flurry::HashMapRef

source ·
pub struct HashMapRef<'map, K, V, S = DefaultHashBuilder> { /* private fields */ }
Expand description

A reference to a HashMap, constructed with HashMap::pin or HashMap::with_guard.

The current thread will be pinned for the duration of this reference. Keep in mind that this prevents the collection of garbage generated by the map.

Implementations§

source§

impl<K, V, S> HashMapRef<'_, K, V, S>

source

pub fn len(&self) -> usize

Returns the number of entries in the map.

See also HashMap::len.

source

pub fn is_empty(&self) -> bool

Returns true if the map is empty. Otherwise returns false.

See also HashMap::is_empty.

source

pub fn iter(&self) -> Iter<'_, K, V>

An iterator visiting all key-value pairs in arbitrary order.

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

See also HashMap::iter.

source

pub fn keys(&self) -> Keys<'_, K, V>

An iterator visiting all keys in arbitrary order.

The iterator element type is &'g K.

See also HashMap::keys.

source

pub fn values(&self) -> Values<'_, K, V>

An iterator visiting all values in arbitrary order.

The iterator element type is &'g V.

See also HashMap::values.

source§

impl<K, V, S> HashMapRef<'_, K, V, S>
where K: Clone + Ord,

source

pub fn reserve(&self, additional: usize)

Tries to reserve capacity for at least additional more elements to be inserted in the HashMap.

The collection may reserve more space to avoid frequent reallocations.

See also HashMap::reserve.

source§

impl<K, V, S> HashMapRef<'_, K, V, S>
where K: Hash + Ord, S: BuildHasher,

source

pub fn contains_key<Q>(&self, key: &Q) -> bool
where K: Borrow<Q>, Q: ?Sized + Hash + Ord,

Returns true if the map contains a value for the specified key.

See also HashMap::contains_key.

source

pub fn get<'g, Q>(&'g self, key: &Q) -> Option<&'g V>
where K: Borrow<Q>, Q: ?Sized + Hash + Ord,

Returns a reference to the value corresponding to the key.

See also HashMap::get.

source

pub fn get_key_value<'g, Q>(&'g self, key: &Q) -> Option<(&'g K, &'g V)>
where K: Borrow<Q>, Q: ?Sized + Hash + Ord,

Returns the key-value pair corresponding to key.

See also HashMap::get_key_value.

source§

impl<K, V, S> HashMapRef<'_, K, V, S>
where K: Clone + Ord,

source

pub fn clear(&self)

Clears the map, removing all key-value pairs.

See also HashMap::clear.

source§

impl<K, V, S> HashMapRef<'_, K, V, S>
where K: Sync + Send + Clone + Hash + Ord, V: Sync + Send, S: BuildHasher,

source

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

Inserts a key-value pair into the map.

See also HashMap::insert.

source

pub fn try_insert(&self, key: K, value: V) -> Result<&V, TryInsertError<'_, V>>

Inserts a key-value pair into the map unless the key already exists.

See also HashMap::try_insert.

source

pub fn compute_if_present<'g, Q, F>( &'g self, key: &Q, remapping_function: F ) -> Option<&'g V>
where K: Borrow<Q>, Q: ?Sized + Hash + Ord, F: FnOnce(&K, &V) -> Option<V>,

If the value for the specified key is present, attempts to compute a new mapping given the key and its current mapped value.

See also HashMap::compute_if_present.

source

pub fn remove<'g, Q>(&'g self, key: &Q) -> Option<&'g V>
where K: Borrow<Q>, Q: ?Sized + Hash + Ord,

Removes a key-value pair from the map, and returns the removed value (if any).

See also HashMap::remove.

source

pub fn remove_entry<'g, Q>(&'g self, key: &Q) -> Option<(&'g K, &'g V)>
where K: Borrow<Q>, Q: ?Sized + Hash + Ord,

Removes a key from the map, returning the stored key and value if the key was previously in the map.

See also HashMap::remove_entry.

source

pub fn retain<F>(&self, f: F)
where F: FnMut(&K, &V) -> bool,

Retains only the elements specified by the predicate.

See also HashMap::retain.

source

pub fn retain_force<F>(&self, f: F)
where F: FnMut(&K, &V) -> bool,

Retains only the elements specified by the predicate.

See also HashMap::retain_force.

Trait Implementations§

source§

impl<K, V, S> Clone for HashMapRef<'_, K, V, S>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<K, V, S> Debug for HashMapRef<'_, K, V, S>
where K: Debug, V: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<K, Q, V, S> Index<&Q> for HashMapRef<'_, K, V, S>
where K: Hash + Ord + Borrow<Q>, Q: ?Sized + Hash + Ord, S: BuildHasher,

§

type Output = V

The returned type after indexing.
source§

fn index(&self, key: &Q) -> &V

Performs the indexing (container[index]) operation. Read more
source§

impl<'g, K, V, S> IntoIterator for &'g HashMapRef<'_, K, V, S>

§

type IntoIter = Iter<'g, K, V>

Which kind of iterator are we turning this into?
§

type Item = (&'g K, &'g V)

The type of the elements being iterated over.
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<K, V, S> PartialEq<HashMap<K, V, S>> for HashMapRef<'_, K, V, S>
where K: Hash + Ord, V: PartialEq, S: BuildHasher,

source§

fn eq(&self, other: &HashMap<K, V, S>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<K, V, S> PartialEq<HashMapRef<'_, K, V, S>> for HashMap<K, V, S>
where K: Hash + Ord, V: PartialEq, S: BuildHasher,

source§

fn eq(&self, other: &HashMapRef<'_, K, V, S>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<K, V, S> PartialEq for HashMapRef<'_, K, V, S>
where K: Hash + Ord, V: PartialEq, S: BuildHasher,

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<K, V, S> Eq for HashMapRef<'_, K, V, S>
where K: Hash + Ord, V: Eq, S: BuildHasher,

Auto Trait Implementations§

§

impl<'map, K, V, S> Freeze for HashMapRef<'map, K, V, S>

§

impl<'map, K, V, S> RefUnwindSafe for HashMapRef<'map, K, V, S>
where S: RefUnwindSafe,

§

impl<'map, K, V, S = DefaultHashBuilder> !Send for HashMapRef<'map, K, V, S>

§

impl<'map, K, V, S = DefaultHashBuilder> !Sync for HashMapRef<'map, K, V, S>

§

impl<'map, K, V, S> Unpin for HashMapRef<'map, K, V, S>

§

impl<'map, K, V, S> UnwindSafe for HashMapRef<'map, K, V, S>
where S: RefUnwindSafe,

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.