rustc_type_ir::data_structures

Struct SsoHashSet

source
pub struct SsoHashSet<T> {
    map: SsoHashMap<T, ()>,
}
Expand description

Small-storage-optimized implementation of a set.

Stores elements in a small array up to a certain length and switches to HashSet when that length is exceeded.

Fields§

§map: SsoHashMap<T, ()>

Implementations§

source§

impl<T> SsoHashSet<T>

source

pub fn new() -> SsoHashSet<T>

Creates an empty SsoHashSet.

source

pub fn with_capacity(cap: usize) -> SsoHashSet<T>

Creates an empty SsoHashSet with the specified capacity.

source

pub fn clear(&mut self)

Clears the set, removing all values.

source

pub fn capacity(&self) -> usize

Returns the number of elements the set can hold without reallocating.

source

pub fn len(&self) -> usize

Returns the number of elements in the set.

source

pub fn is_empty(&self) -> bool

Returns true if the set contains no elements.

source

pub fn iter(&self) -> impl Iterator<Item = &T>

An iterator visiting all elements in arbitrary order. The iterator element type is &'a T.

source

pub fn drain(&mut self) -> impl Iterator<Item = T>

Clears the set, returning all elements in an iterator.

source§

impl<T> SsoHashSet<T>
where T: Eq + Hash,

source

pub fn reserve(&mut self, additional: usize)

Reserves capacity for at least additional more elements to be inserted in the SsoHashSet. The collection may reserve more space to avoid frequent reallocations.

source

pub fn shrink_to_fit(&mut self)

Shrinks the capacity of the set as much as possible. It will drop down as much as possible while maintaining the internal rules and possibly leaving some space in accordance with the resize policy.

source

pub fn retain<F>(&mut self, f: F)
where F: FnMut(&T) -> bool,

Retains only the elements specified by the predicate.

source

pub fn take(&mut self, value: &T) -> Option<T>

Removes and returns the value in the set, if any, that is equal to the given one.

source

pub fn get(&self, value: &T) -> Option<&T>

Returns a reference to the value in the set, if any, that is equal to the given value.

source

pub fn insert(&mut self, elem: T) -> bool

Adds a value to the set.

Returns whether the value was newly inserted. That is:

  • If the set did not previously contain this value, true is returned.
  • If the set already contained this value, false is returned.
source

pub fn remove(&mut self, value: &T) -> bool

Removes a value from the set. Returns whether the value was present in the set.

source

pub fn contains(&self, value: &T) -> bool

Returns true if the set contains a value.

Trait Implementations§

source§

impl<T> Clone for SsoHashSet<T>
where T: Clone,

source§

fn clone(&self) -> SsoHashSet<T>

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<T> Debug for SsoHashSet<T>
where T: Debug,

source§

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

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

impl<T> Default for SsoHashSet<T>

source§

fn default() -> SsoHashSet<T>

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

impl<'a, T> Extend<&'a T> for SsoHashSet<T>
where T: 'a + Eq + Hash + Copy,

source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = &'a T>,

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

fn extend_one(&mut self, _: &'a T)

🔬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<T> Extend<T> for SsoHashSet<T>
where T: Eq + Hash,

source§

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

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

fn extend_one(&mut self, item: T)

🔬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<T> FromIterator<T> for SsoHashSet<T>
where T: Eq + Hash,

source§

fn from_iter<I>(iter: I) -> SsoHashSet<T>
where I: IntoIterator<Item = T>,

Creates a value from an iterator. Read more
source§

impl<'a, T> IntoIterator for &'a SsoHashSet<T>

source§

type IntoIter = Map<Either<Map<Iter<'a, (T, ())>, fn(_: &'a (T, ())) -> (&'a T, &'a ())>, Iter<'a, T, ()>>, fn(_: (&'a T, &'a ())) -> &'a T>

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

type Item = &'a T

The type of the elements being iterated over.
source§

fn into_iter( self, ) -> Map<Either<Map<Iter<'a, (T, ())>, fn(_: &'a (T, ())) -> (&'a T, &'a ())>, Iter<'a, T, ()>>, fn(_: (&'a T, &'a ())) -> &'a T>

Creates an iterator from a value. Read more
source§

impl<T> IntoIterator for SsoHashSet<T>

source§

type IntoIter = Map<Either<IntoIter<(T, ()), 8>, IntoIter<T, ()>>, fn(_: (T, ())) -> T>

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

type Item = T

The type of the elements being iterated over.
source§

fn into_iter( self, ) -> Map<Either<IntoIter<(T, ()), 8>, IntoIter<T, ()>>, fn(_: (T, ())) -> T>

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<T> Freeze for SsoHashSet<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for SsoHashSet<T>
where T: RefUnwindSafe,

§

impl<T> Send for SsoHashSet<T>
where T: Send,

§

impl<T> Sync for SsoHashSet<T>
where T: Sync,

§

impl<T> Unpin for SsoHashSet<T>
where T: Unpin,

§

impl<T> UnwindSafe for SsoHashSet<T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Aligned for T

source§

const ALIGN: Alignment = _

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<T, R> CollectAndApply<T, R> for T

source§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

source§

type Output = R

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

source§

type Output = T

Should always be Self
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<I, T, U> Upcast<I, U> for T
where U: UpcastFrom<I, T>,

source§

fn upcast(self, interner: I) -> U

source§

impl<I, T> UpcastFrom<I, T> for T

source§

fn upcast_from(from: T, _tcx: I) -> T

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: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.