pub struct UnordMap<K: Eq + Hash, V> {
inner: FxHashMap<K, V>,
}
Expand description
This is a map collection type that tries very hard to not expose any internal iteration. This is a useful property when trying to uphold the determinism invariants imposed by the query system.
This collection type is a good choice for map-like collections the keys of which don’t have a semantic ordering.
See MCP 533 for more information.
Fields§
§inner: FxHashMap<K, V>
Implementations§
Source§impl<K: Eq + Hash, V> UnordMap<K, V>
impl<K: Eq + Hash, V> UnordMap<K, V>
pub fn with_capacity(capacity: usize) -> Self
pub fn len(&self) -> usize
pub fn insert(&mut self, k: K, v: V) -> Option<V>
pub fn try_insert( &mut self, k: K, v: V, ) -> Result<&mut V, OccupiedError<'_, K, V>>
pub fn contains_key<Q>(&self, k: &Q) -> bool
pub fn is_empty(&self) -> bool
pub fn entry(&mut self, key: K) -> Entry<'_, K, V>
pub fn get<Q>(&self, k: &Q) -> Option<&V>
pub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
pub fn remove<Q>(&mut self, k: &Q) -> Option<V>
pub fn items(&self) -> UnordItems<(&K, &V), impl Iterator<Item = (&K, &V)>>
pub fn into_items(self) -> UnordItems<(K, V), impl Iterator<Item = (K, V)>>
pub fn keys(&self) -> UnordItems<&K, impl Iterator<Item = &K>>
Sourcepub fn to_sorted<HCX>(&self, hcx: &HCX, cache_sort_key: bool) -> Vec<(&K, &V)>where
K: ToStableHashKey<HCX>,
pub fn to_sorted<HCX>(&self, hcx: &HCX, cache_sort_key: bool) -> Vec<(&K, &V)>where
K: ToStableHashKey<HCX>,
Returns the entries of this map in stable sort order (as defined by ToStableHashKey
).
The cache_sort_key
parameter controls if slice::sort_by_cached_key or
slice::sort_unstable_by_key will be used for sorting the vec. Use
cache_sort_key
when the ToStableHashKey::to_stable_hash_key implementation
for K
is expensive (e.g. a DefId -> DefPathHash
lookup).
Sourcepub fn to_sorted_stable_ord(&self) -> Vec<(&K, &V)>where
K: StableCompare,
pub fn to_sorted_stable_ord(&self) -> Vec<(&K, &V)>where
K: StableCompare,
Returns the entries of this map in stable sort order (as defined by StableCompare
).
This method can be much more efficient than into_sorted
because it does not need
to transform keys to their ToStableHashKey
equivalent.
Sourcepub fn into_sorted<HCX>(self, hcx: &HCX, cache_sort_key: bool) -> Vec<(K, V)>where
K: ToStableHashKey<HCX>,
pub fn into_sorted<HCX>(self, hcx: &HCX, cache_sort_key: bool) -> Vec<(K, V)>where
K: ToStableHashKey<HCX>,
Returns the entries of this map in stable sort order (as defined by ToStableHashKey
).
The cache_sort_key
parameter controls if slice::sort_by_cached_key or
slice::sort_unstable_by_key will be used for sorting the vec. Use
cache_sort_key
when the ToStableHashKey::to_stable_hash_key implementation
for K
is expensive (e.g. a DefId -> DefPathHash
lookup).
Sourcepub fn into_sorted_stable_ord(self) -> Vec<(K, V)>where
K: StableCompare,
pub fn into_sorted_stable_ord(self) -> Vec<(K, V)>where
K: StableCompare,
Returns the entries of this map in stable sort order (as defined by StableCompare
).
This method can be much more efficient than into_sorted
because it does not need
to transform keys to their ToStableHashKey
equivalent.
Sourcepub fn values_sorted<HCX>(
&self,
hcx: &HCX,
cache_sort_key: bool,
) -> impl Iterator<Item = &V>where
K: ToStableHashKey<HCX>,
pub fn values_sorted<HCX>(
&self,
hcx: &HCX,
cache_sort_key: bool,
) -> impl Iterator<Item = &V>where
K: ToStableHashKey<HCX>,
Returns the values of this map in stable sort order (as defined by K’s
ToStableHashKey
implementation).
The cache_sort_key
parameter controls if slice::sort_by_cached_key or
slice::sort_unstable_by_key will be used for sorting the vec. Use
cache_sort_key
when the ToStableHashKey::to_stable_hash_key implementation
for K
is expensive (e.g. a DefId -> DefPathHash
lookup).
Trait Implementations§
Source§impl<K: Hash + Eq, V> Extend<(K, V)> for UnordMap<K, V>
impl<K: Hash + Eq, V> Extend<(K, V)> for UnordMap<K, V>
Source§fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl<K: Hash + Eq, V, I: Iterator<Item = (K, V)>> From<UnordItems<(K, V), I>> for UnordMap<K, V>
impl<K: Hash + Eq, V, I: Iterator<Item = (K, V)>> From<UnordItems<(K, V), I>> for UnordMap<K, V>
Source§fn from(items: UnordItems<(K, V), I>) -> Self
fn from(items: UnordItems<(K, V), I>) -> Self
Source§impl<HCX, K: Hash + Eq + HashStable<HCX>, V: HashStable<HCX>> HashStable<HCX> for UnordMap<K, V>
impl<HCX, K: Hash + Eq + HashStable<HCX>, V: HashStable<HCX>> HashStable<HCX> for UnordMap<K, V>
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher)
impl<K: Eq + Eq + Hash, V: Eq> Eq for UnordMap<K, V>
impl<K, V> !IntoIterator for UnordMap<K, V>
impl<K: Eq + Hash, V> StructuralPartialEq for UnordMap<K, V>
impl<K: Eq + Hash, V> UnordCollection for UnordMap<K, V>
Auto Trait Implementations§
impl<K, V> DynSend for UnordMap<K, V>
impl<K, V> DynSync for UnordMap<K, V>
impl<K, V> Freeze for UnordMap<K, V>
impl<K, V> RefUnwindSafe for UnordMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for UnordMap<K, V>
impl<K, V> Sync for UnordMap<K, V>
impl<K, V> Unpin for UnordMap<K, V>
impl<K, V> UnwindSafe for UnordMap<K, V>where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<C, T> ExtendUnord<T> for Cwhere
C: Extend<T> + UnordCollection,
impl<C, T> ExtendUnord<T> for Cwhere
C: Extend<T> + UnordCollection,
Source§fn extend_unord<I>(&mut self, items: UnordItems<T, I>)where
I: Iterator<Item = T>,
fn extend_unord<I>(&mut self, items: UnordItems<T, I>)where
I: Iterator<Item = T>,
UnordItems
.
This method is called extend_unord
instead of just extend
so it
does not conflict with Extend::extend
. Otherwise there would be many
places where the two methods would have to be explicitly disambiguated
via UFCS.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes