Skip to main content

HashMap

Struct HashMap 

Source
pub struct HashMap<K, V, S = RandomState> { /* private fields */ }
Expand description

A wrapper type around [hashbrown::hash_map::HashMap] that only exposes fallible allocation.

Implementations§

Source§

impl<K, V> HashMap<K, V, RandomState>

Source

pub fn new() -> Self

Same as [hashbrown::hash_map::HashMap::new].

Source§

impl<K, V> HashMap<K, V, RandomState>
where K: Eq + Hash,

Source

pub fn with_capacity(capacity: usize) -> Result<Self, OutOfMemory>

Same as [hashbrown::hash_map::HashMap::with_capacity] but returns an error on allocation failure.

Source§

impl<K, V, S> HashMap<K, V, S>

Source

pub const fn with_hasher(hasher: S) -> Self

Same as [hashbrown::hash_map::HashMap::with_hasher].

Source

pub fn hasher(&self) -> &S

Same as [hashbrown::hash_map::HashMap::hasher].

Source

pub fn capacity(&self) -> usize

Same as [hashbrown::hash_map::HashMap::capacity].

Source

pub fn len(&self) -> usize

Same as [hashbrown::hash_map::HashMap::len].

Source

pub fn is_empty(&self) -> bool

Same as [hashbrown::hash_map::HashMap::is_empty].

Source

pub fn drain(&mut self) -> Drain<'_, K, V>

Same as [hashbrown::hash_map::HashMap::drain].

Source

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

Same as [hashbrown::hash_map::HashMap::retain].

Source

pub fn extract_if<F>(&mut self, f: F) -> ExtractIf<'_, K, V, F>
where F: FnMut(&K, &mut V) -> bool,

Same as [hashbrown::hash_map::HashMap::extract_if].

Source

pub fn clear(&mut self)

Same as [hashbrown::hash_map::HashMap::clear].

Source

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

Same as [hashbrown::hash_map::HashMap::iter].

Source

pub fn iter_mut(&mut self) -> IterMut<'_, K, V>

Same as [hashbrown::hash_map::HashMap::iter_mut].

Source§

impl<K, V, S> HashMap<K, V, S>
where K: Eq + Hash, S: BuildHasher,

Source

pub fn with_capacity_and_hasher( capacity: usize, hasher: S, ) -> Result<Self, OutOfMemory>

Same as [hashbrown::hash_map::HashMap::with_capacity_and_hasher] but returns an error on allocation failure.

Source

pub fn reserve(&mut self, additional: usize) -> Result<(), OutOfMemory>

Same as [hashbrown::hash_map::HashMap::reserve] but returns an error on allocation failure.

Source

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

Same as [hashbrown::hash_map::HashMap::contains_key].

Source

pub fn get<Q>(&self, value: &Q) -> Option<&V>
where Q: Hash + Eq + ?Sized, K: Borrow<Q>,

Same as [hashbrown::hash_map::HashMap::get].

Source

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

Same as [hashbrown::hash_map::HashMap::insert] but returns an error on allocation failure.

Source

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

Same as [hashbrown::hash_map::HashMap::remove].

Trait Implementations§

Source§

impl<K, V, S> Debug for HashMap<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, V, S> Default for HashMap<K, V, S>
where S: Default,

Source§

fn default() -> Self

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

impl<'a, K, V, S> IntoIterator for &'a HashMap<K, V, S>

Source§

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

The type of the elements being iterated over.
Source§

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

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, K, V, S> IntoIterator for &'a mut HashMap<K, V, S>

Source§

type Item = (&'a K, &'a mut V)

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, K, V>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<K, V, S> IntoIterator for HashMap<K, V, S>

Source§

type Item = (K, V)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<K, V>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<K, V, S> PartialEq for HashMap<K, V, S>
where K: Eq + Hash, V: PartialEq, S: BuildHasher,

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<K, V, S> TryClone for HashMap<K, V, S>
where K: Eq + Hash + TryClone, V: TryClone, S: BuildHasher + TryClone,

Source§

fn try_clone(&self) -> Result<Self, OutOfMemory>

Attempt to clone self, returning an error if any allocation fails during cloning.
Source§

impl<K, V, S> Eq for HashMap<K, V, S>
where K: Eq + Hash, V: Eq, S: BuildHasher,

Auto Trait Implementations§

§

impl<K, V, S> Freeze for HashMap<K, V, S>
where S: Freeze,

§

impl<K, V, S> RefUnwindSafe for HashMap<K, V, S>

§

impl<K, V, S> Send for HashMap<K, V, S>
where S: Send, K: Send, V: Send,

§

impl<K, V, S> Sync for HashMap<K, V, S>
where S: Sync, K: Sync, V: Sync,

§

impl<K, V, S> Unpin for HashMap<K, V, S>
where S: Unpin, K: Unpin, V: Unpin,

§

impl<K, V, S> UnwindSafe for HashMap<K, V, S>
where K: UnwindSafe, V: UnwindSafe, S: UnwindSafe,

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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.