rustc_data_structures::unord

Struct UnordSet

Source
pub struct UnordSet<V: Eq + Hash> {
    inner: FxHashSet<V>,
}
Expand description

This is a set 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 set-like collections the keys of which don’t have a semantic ordering.

See MCP 533 for more information.

Fields§

§inner: FxHashSet<V>

Implementations§

Source§

impl<V: Eq + Hash> UnordSet<V>

Source

pub fn new() -> Self

Source

pub fn with_capacity(capacity: usize) -> Self

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn insert(&mut self, v: V) -> bool

Source

pub fn contains<Q>(&self, v: &Q) -> bool
where V: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source

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

Source

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

Source

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

Source

pub fn to_sorted<HCX>(&self, hcx: &HCX, cache_sort_key: bool) -> Vec<&V>
where V: ToStableHashKey<HCX>,

Returns the items of this set 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 V is expensive (e.g. a DefId -> DefPathHash lookup).

Source

pub fn to_sorted_stable_ord(&self) -> Vec<&V>
where V: StableCompare,

Returns the items of this set in stable sort order (as defined by StableCompare). This method is much more efficient than into_sorted because it does not need to transform keys to their ToStableHashKey equivalent.

Source

pub fn into_sorted_stable_ord(self) -> Vec<V>
where V: StableCompare,

Returns the items of this set in stable sort order (as defined by StableCompare). This method is 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<V>
where V: ToStableHashKey<HCX>,

Returns the items of this set 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 V is expensive (e.g. a DefId -> DefPathHash lookup).

Source

pub fn clear(&mut self)

Trait Implementations§

Source§

impl<V: Clone + Eq + Hash> Clone for UnordSet<V>

Source§

fn clone(&self) -> UnordSet<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<V: Debug + Eq + Hash> Debug for UnordSet<V>

Source§

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

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

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

Source§

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

Source§

impl<V: Eq + Hash> Default for UnordSet<V>

Source§

fn default() -> Self

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

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

Source§

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

Source§

impl<V: Hash + Eq> Extend<V> for UnordSet<V>

Source§

fn extend<T: IntoIterator<Item = 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<V: Hash + Eq> From<HashSet<V, FxBuildHasher>> for UnordSet<V>

Source§

fn from(value: FxHashSet<V>) -> Self

Converts to this type from the input type.
Source§

impl<V: Hash + Eq, I: Iterator<Item = V>> From<UnordItems<V, I>> for UnordSet<V>

Source§

fn from(value: UnordItems<V, I>) -> Self

Converts to this type from the input type.
Source§

impl<V: Hash + Eq> FromIterator<V> for UnordSet<V>

Source§

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

Creates a value from an iterator. Read more
Source§

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

Source§

fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher)

Source§

impl<V: PartialEq + Eq + Hash> PartialEq for UnordSet<V>

Source§

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

Source§

impl<V> !IntoIterator for UnordSet<V>

Source§

impl<V: Eq + Hash> StructuralPartialEq for UnordSet<V>

Source§

impl<V: Eq + Hash> UnordCollection for UnordSet<V>

Auto Trait Implementations§

§

impl<V> DynSend for UnordSet<V>
where V: DynSend,

§

impl<V> DynSync for UnordSet<V>
where V: DynSync,

§

impl<V> Freeze for UnordSet<V>

§

impl<V> RefUnwindSafe for UnordSet<V>
where V: RefUnwindSafe,

§

impl<V> Send for UnordSet<V>
where V: Send,

§

impl<V> Sync for UnordSet<V>
where V: Sync,

§

impl<V> Unpin for UnordSet<V>
where V: Unpin,

§

impl<V> UnwindSafe for UnordSet<V>
where 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§

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

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,

Source§

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>,

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