pub struct UnorderedHashMap<Key: Hash + Eq, Value>(/* private fields */);
Expand description

A hash map that does not care about the order of insertion. In particular, it does not support iterating, in order to guarantee deterministic compilation. For an iterable version see OrderedHashMap.

Implementations§

source§

impl<Key: Hash + Eq, Value> UnorderedHashMap<Key, Value>

source

pub fn get<Q>(&self, key: &Q) -> Option<&Value>
where Key: Borrow<Q>, Q: Hash + Eq + ?Sized,

Returns a reference to the value corresponding to the key.

The key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed form must match those for the key type.

source

pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut Value>
where Key: Borrow<Q>, Q: Hash + Eq + ?Sized,

Returns a mutable reference to the value corresponding to the key.

The key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed form must match those for the key type.

source

pub fn insert(&mut self, key: Key, value: Value) -> Option<Value>

Inserts a key-value pair into the map.

If the map did not have this key present, None is returned.

If the map did have this key present, the value is updated, and the old value is returned. The key is not updated, though; this matters for types that can be == without being identical.

source

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

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

The key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed form must match those for the key type.

source

pub fn entry(&mut self, key: Key) -> Entry<'_, Key, Value>

Gets the given key’s corresponding entry in the map for in-place manipulation.

source

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

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

source

pub fn len(&self) -> usize

Returns the number of elements in the map.

source

pub fn is_empty(&self) -> bool

Returns true if the map contains no elements.

Trait Implementations§

source§

impl<Key: Clone + Hash + Eq, Value: Clone> Clone for UnorderedHashMap<Key, Value>

source§

fn clone(&self) -> UnorderedHashMap<Key, Value>

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<Key: Debug + Hash + Eq, Value: Debug> Debug for UnorderedHashMap<Key, Value>

source§

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

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

impl<Key: Hash + Eq, Value> Default for UnorderedHashMap<Key, Value>

source§

fn default() -> Self

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

impl<Key: Hash + Eq, Value, const N: usize> From<[(Key, Value); N]> for UnorderedHashMap<Key, Value>

source§

fn from(items: [(Key, Value); N]) -> Self

Converts to this type from the input type.
source§

impl<Key: Hash + Eq, Value> FromIterator<(Key, Value)> for UnorderedHashMap<Key, Value>

source§

fn from_iter<T: IntoIterator<Item = (Key, Value)>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl<Key, Q, Value> Index<&Q> for UnorderedHashMap<Key, Value>
where Key: Eq + Hash + Borrow<Q>, Q: Eq + Hash + ?Sized,

§

type Output = Value

The returned type after indexing.
source§

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

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

impl<Key: PartialEq + Hash + Eq, Value: PartialEq> PartialEq for UnorderedHashMap<Key, Value>

source§

fn eq(&self, other: &UnorderedHashMap<Key, Value>) -> 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<Key: Eq + Hash + Eq, Value: Eq> Eq for UnorderedHashMap<Key, Value>

source§

impl<Key: Hash + Eq, Value> StructuralEq for UnorderedHashMap<Key, Value>

source§

impl<Key: Hash + Eq, Value> StructuralPartialEq for UnorderedHashMap<Key, Value>

Auto Trait Implementations§

§

impl<Key, Value> RefUnwindSafe for UnorderedHashMap<Key, Value>
where Key: RefUnwindSafe, Value: RefUnwindSafe,

§

impl<Key, Value> Send for UnorderedHashMap<Key, Value>
where Key: Send, Value: Send,

§

impl<Key, Value> Sync for UnorderedHashMap<Key, Value>
where Key: Sync, Value: Sync,

§

impl<Key, Value> Unpin for UnorderedHashMap<Key, Value>
where Key: Unpin, Value: Unpin,

§

impl<Key, Value> UnwindSafe for UnorderedHashMap<Key, Value>
where Key: UnwindSafe, Value: 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
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

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

source§

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
§

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.
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.
source§

impl<T> Upcast<T> for T
where T: ?Sized,

source§

fn upcast(&self) -> &T

source§

impl<T> UpcastMut<T> for T
where T: ?Sized,

source§

fn upcast_mut(&mut self) -> &mut T