Struct rustc_data_structures::unord::UnordMap

source ·
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>

source

pub fn with_capacity(capacity: usize) -> Self

source

pub fn len(&self) -> usize

source

pub fn insert(&mut self, k: K, v: V) -> Option<V>

source

pub fn try_insert( &mut self, k: K, v: V, ) -> Result<&mut V, OccupiedError<'_, K, V>>

source

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

source

pub fn is_empty(&self) -> bool

source

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

source

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

source

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

source

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

source

pub fn items(&self) -> UnordItems<(&K, &V), impl Iterator<Item = (&K, &V)>>

source

pub fn into_items(self) -> UnordItems<(K, V), impl Iterator<Item = (K, V)>>

source

pub fn keys(&self) -> UnordItems<&K, impl Iterator<Item = &K>>

source

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).

source

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.

source

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).

source

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.

source

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: Clone + Eq + Hash, V: Clone> Clone for UnordMap<K, V>

source§

fn clone(&self) -> UnordMap<K, V>

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: Debug + Eq + Hash, V: Debug> Debug for UnordMap<K, V>

source§

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

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

impl<K, V, __D: Decoder> Decodable<__D> for UnordMap<K, V>
where K: Decodable<__D> + Eq + Hash, V: Decodable<__D>,

source§

fn decode(__decoder: &mut __D) -> Self

source§

impl<K: Eq + Hash, V> Default for UnordMap<K, V>

source§

fn default() -> Self

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

impl<K, V, __E: Encoder> Encodable<__E> for UnordMap<K, V>
where K: Encodable<__E> + Eq + Hash, V: Encodable<__E>,

source§

fn encode(&self, __encoder: &mut __E)

source§

impl<K: Hash + Eq, V> Extend<(K, V)> for UnordMap<K, V>

source§

fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

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

Converts to this type from the input type.
source§

impl<K: Hash + Eq, V> FromIterator<(K, V)> for UnordMap<K, V>

source§

fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl<HCX, K: Hash + Eq + HashStable<HCX>, V: HashStable<HCX>> HashStable<HCX> for UnordMap<K, V>

source§

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,

§

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<K, V> !IntoIterator for UnordMap<K, V>

§

type Item

The type of the elements being iterated over.
§

type IntoIter: Iterator<Item = Self::Item>

Which kind of iterator are we turning this into?
1.0.0 · source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<K: PartialEq + Eq + Hash, V: PartialEq> PartialEq for UnordMap<K, V>

source§

fn eq(&self, other: &UnordMap<K, V>) -> 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: Eq + Eq + Hash, V: Eq> Eq for UnordMap<K, V>

source§

impl<K: Eq + Hash, V> StructuralPartialEq for UnordMap<K, V>

source§

impl<K: Eq + Hash, V> UnordCollection for UnordMap<K, V>

Auto Trait Implementations§

§

impl<K, V> DynSend for UnordMap<K, V>
where K: DynSend, V: DynSend,

§

impl<K, V> DynSync for UnordMap<K, V>
where K: DynSync, V: DynSync,

§

impl<K, V> Freeze for UnordMap<K, V>

§

impl<K, V> RefUnwindSafe for UnordMap<K, V>

§

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> Aligned for T

source§

const ALIGN: Alignment = const ALIGN: Alignment = Alignment::of::<Self>();

Alignment of Self.
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> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

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

source§

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

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

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

source§

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

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

impl<C, T> ExtendUnord<T> for C
where C: Extend<T> + UnordCollection,

source§

fn extend_unord<I>(&mut self, items: UnordItems<T, I>)
where I: Iterator<Item = T>,

Extend this unord collection with the given 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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<'a, T> Captures<'a> for T
where 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