pub struct UnordMap<K: Eq + Hash, V> { /* private fields */ }
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.
Implementations§
source§impl<K: Eq + Hash, V> UnordMap<K, V>
impl<K: Eq + Hash, V> UnordMap<K, V>
pub fn len(&self) -> usize
pub fn insert(&mut self, k: K, v: V) -> Option<V>
pub fn contains_key<Q>(&self, k: &Q) -> boolwhere K: Borrow<Q>, Q: Hash + Eq + ?Sized,
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>where K: Borrow<Q>, Q: Hash + Eq + ?Sized,
pub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>where K: Borrow<Q>, Q: Hash + Eq + ?Sized,
pub fn remove<Q>(&mut self, k: &Q) -> Option<V>where K: Borrow<Q>, Q: Hash + Eq + ?Sized,
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 extend<I: Iterator<Item = (K, V)>>( &mut self, items: UnordItems<(K, V), I> )
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: Ord + StableOrd + Copy,
pub fn to_sorted_stable_ord(&self) -> Vec<(K, &V)>where K: Ord + StableOrd + Copy,
Returns the entries of this map in stable sort order (as defined by StableOrd
).
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 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, V, __D: Decoder> Decodable<__D> for UnordMap<K, V>where
K: Decodable<__D> + Eq + Hash,
V: Decodable<__D>,
impl<K, V, __D: Decoder> Decodable<__D> for UnordMap<K, V>where K: Decodable<__D> + Eq + Hash, V: Decodable<__D>,
source§impl<K, V, __E: Encoder> Encodable<__E> for UnordMap<K, V>where
K: Encodable<__E> + Eq + Hash,
V: Encodable<__E>,
impl<K, V, __E: Encoder> Encodable<__E> for UnordMap<K, V>where K: Encodable<__E> + Eq + Hash, V: Encodable<__E>,
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)
source§impl<K, Q, V> Index<&Q> for UnordMap<K, V>where
K: Eq + Hash + Borrow<Q>,
Q: Eq + Hash + ?Sized,
impl<K, Q, V> Index<&Q> for UnordMap<K, V>where K: Eq + Hash + Borrow<Q>, Q: Eq + Hash + ?Sized,
source§impl<K, V> !IntoIterator for UnordMap<K, V>
impl<K, V> !IntoIterator for UnordMap<K, V>
source§impl<K: PartialEq + Eq + Hash, V: PartialEq> PartialEq<UnordMap<K, V>> for UnordMap<K, V>
impl<K: PartialEq + Eq + Hash, V: PartialEq> PartialEq<UnordMap<K, V>> for UnordMap<K, V>
impl<K: Eq + Eq + Hash, V: Eq> Eq for UnordMap<K, V>
impl<K: Eq + Hash, V> StructuralEq for UnordMap<K, V>
impl<K: Eq + Hash, V> StructuralPartialEq for UnordMap<K, V>
Auto Trait Implementations§
impl<K, V> RefUnwindSafe for UnordMap<K, V>where K: RefUnwindSafe, V: RefUnwindSafe,
impl<K, V> Send for UnordMap<K, V>where K: Send, V: Send,
impl<K, V> Sync for UnordMap<K, V>where K: Sync, V: Sync,
impl<K, V> Unpin for UnordMap<K, V>where K: Unpin, V: Unpin,
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<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.