pub struct UnordSet<V: Eq + Hash> { /* private fields */ }
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.
Implementations§
source§impl<V: Eq + Hash> UnordSet<V>
impl<V: Eq + Hash> UnordSet<V>
pub fn new() -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn insert(&mut self, v: V) -> bool
pub fn contains<Q>(&self, v: &Q) -> boolwhere V: Borrow<Q>, Q: Hash + Eq + ?Sized,
pub fn remove<Q>(&mut self, k: &Q) -> boolwhere V: Borrow<Q>, Q: Hash + Eq + ?Sized,
pub fn items(&self) -> UnordItems<&V, impl Iterator<Item = &V>>
pub fn into_items(self) -> UnordItems<V, impl Iterator<Item = V>>
sourcepub fn to_sorted<HCX>(&self, hcx: &HCX, cache_sort_key: bool) -> Vec<&V>where
V: ToStableHashKey<HCX>,
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).
sourcepub fn to_sorted_stable_ord(&self) -> Vec<V>where
V: Ord + StableOrd + Copy,
pub fn to_sorted_stable_ord(&self) -> Vec<V>where V: Ord + StableOrd + Copy,
Returns the items of this set in stable sort order (as defined by
StableOrd
). This method is 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<V>where
V: ToStableHashKey<HCX>,
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).
pub fn extend_unord<I: Iterator<Item = V>>(&mut self, items: UnordItems<V, I>)
pub fn clear(&mut self)
Trait Implementations§
source§impl<V: Hash + Eq> Extend<V> for UnordSet<V>
impl<V: Hash + Eq> Extend<V> for UnordSet<V>
source§fn extend<T: IntoIterator<Item = V>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = 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<V: Hash + Eq> FromIterator<V> for UnordSet<V>
impl<V: Hash + Eq> FromIterator<V> for UnordSet<V>
source§fn from_iter<T: IntoIterator<Item = V>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = V>>(iter: T) -> Self
source§impl<HCX, V: Hash + Eq + HashStable<HCX>> HashStable<HCX> for UnordSet<V>
impl<HCX, V: Hash + Eq + HashStable<HCX>> HashStable<HCX> for UnordSet<V>
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher)
source§impl<V> !IntoIterator for UnordSet<V>
impl<V> !IntoIterator for UnordSet<V>
source§impl<V: PartialEq + Eq + Hash> PartialEq<UnordSet<V>> for UnordSet<V>
impl<V: PartialEq + Eq + Hash> PartialEq<UnordSet<V>> for UnordSet<V>
impl<V: Eq + Eq + Hash> Eq for UnordSet<V>
impl<V: Eq + Hash> StructuralEq for UnordSet<V>
impl<V: Eq + Hash> StructuralPartialEq for UnordSet<V>
Auto Trait Implementations§
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> 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.