rustc_infer::infer::canonical::ir::data_structures

Enum SsoHashMap

source
pub enum SsoHashMap<K, V> {
    Array(ArrayVec<(K, V), 8>),
    Map(HashMap<K, V, FxBuildHasher>),
}
Expand description

Small-storage-optimized implementation of a map.

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

Variants§

Implementations§

source§

impl<K, V> SsoHashMap<K, V>

source

pub fn new() -> SsoHashMap<K, V>

Creates an empty SsoHashMap.

source

pub fn with_capacity(cap: usize) -> SsoHashMap<K, V>

Creates an empty SsoHashMap with the specified capacity.

source

pub fn clear(&mut self)

Clears the map, removing all key-value pairs. Keeps the allocated memory for reuse.

source

pub fn capacity(&self) -> usize

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

source

pub fn len(&self) -> usize

Returns the number of elements in the map.

source

pub fn is_empty(&self) -> bool

Returns true if the map contains no elements.

source

pub fn iter( &self, ) -> Either<Map<Iter<'_, (K, V)>, fn(_: &(K, V)) -> (&K, &V)>, Iter<'_, K, V>>

An iterator visiting all key-value pairs in arbitrary order. The iterator element type is (&'a K, &'a V).

source

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

An iterator visiting all key-value pairs in arbitrary order, with mutable references to the values. The iterator element type is (&'a K, &'a mut V).

source

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

An iterator visiting all keys in arbitrary order. The iterator element type is &'a K.

source

pub fn values(&self) -> impl Iterator<Item = &V>

An iterator visiting all values in arbitrary order. The iterator element type is &'a V.

source

pub fn values_mut(&mut self) -> impl Iterator<Item = &mut V>

An iterator visiting all values mutably in arbitrary order. The iterator element type is &'a mut V.

source

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

Clears the map, returning all key-value pairs as an iterator. Keeps the allocated memory for reuse.

source§

impl<K, V> SsoHashMap<K, V>
where K: Eq + Hash,

source

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

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

source

pub fn shrink_to_fit(&mut self)

Shrinks the capacity of the map 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(&K, &mut V) -> bool,

Retains only the elements specified by the predicate.

source

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

Inserts a key-value pair into the map.

If the map did not have this key present, None is returned.

If the map did have this key present, the value is updated, and the old value is returned. The key is not updated, though; this matters for types that can be == without being identical. See the [module-level documentation] for more.

source

pub fn remove(&mut self, key: &K) -> Option<V>

Removes a key from the map, returning the value at the key if the key was previously in the map.

source

pub fn remove_entry(&mut self, key: &K) -> Option<(K, V)>

Removes a key from the map, returning the stored key and value if the key was previously in the map.

source

pub fn get(&self, key: &K) -> Option<&V>

Returns a reference to the value corresponding to the key.

source

pub fn get_mut(&mut self, key: &K) -> Option<&mut V>

Returns a mutable reference to the value corresponding to the key.

source

pub fn get_key_value(&self, key: &K) -> Option<(&K, &V)>

Returns the key-value pair corresponding to the supplied key.

source

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

Returns true if the map contains a value for the specified key.

source

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

Gets the given key’s corresponding entry in the map for in-place manipulation.

Trait Implementations§

source§

impl<K, V> Clone for SsoHashMap<K, V>
where K: Clone, V: Clone,

source§

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

Returns a copy of the value. Read more
source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<K, V> Debug for SsoHashMap<K, V>
where K: Debug, V: Debug,

source§

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

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

impl<K, V> Default for SsoHashMap<K, V>

source§

fn default() -> SsoHashMap<K, V>

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

impl<'a, K, V> Extend<(&'a K, &'a V)> for SsoHashMap<K, V>
where K: Eq + Hash + Copy, V: Copy,

source§

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

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

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

🔬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, V> Extend<(K, V)> for SsoHashMap<K, V>
where K: Eq + Hash,

source§

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

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

fn extend_one(&mut self, _: (K, V))

🔬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, V> FromIterator<(K, V)> for SsoHashMap<K, V>
where K: Eq + Hash,

source§

fn from_iter<I>(iter: I) -> SsoHashMap<K, V>
where I: IntoIterator<Item = (K, V)>,

Creates a value from an iterator. Read more
source§

impl<'a, K, V> Index<&'a K> for SsoHashMap<K, V>
where K: Eq + Hash,

source§

type Output = V

The returned type after indexing.
source§

fn index(&self, key: &K) -> &V

Performs the indexing (container[index]) operation. Read more
source§

impl<'a, K, V> IntoIterator for &'a SsoHashMap<K, V>

source§

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

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

type Item = (&'a K, &'a V)

The type of the elements being iterated over.
source§

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

Creates an iterator from a value. Read more
source§

impl<'a, K, V> IntoIterator for &'a mut SsoHashMap<K, V>

source§

type IntoIter = Either<Map<IterMut<'a, (K, V)>, fn(_: &'a mut (K, V)) -> (&'a K, &'a mut V)>, IterMut<'a, K, V>>

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

type Item = (&'a K, &'a mut V)

The type of the elements being iterated over.
source§

fn into_iter( self, ) -> Either<Map<IterMut<'a, (K, V)>, fn(_: &'a mut (K, V)) -> (&'a K, &'a mut V)>, IterMut<'a, K, V>>

Creates an iterator from a value. Read more
source§

impl<K, V> IntoIterator for SsoHashMap<K, V>

source§

type IntoIter = Either<IntoIter<(K, V), 8>, IntoIter<K, V>>

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

type Item = (K, V)

The type of the elements being iterated over.
source§

fn into_iter(self) -> Either<IntoIter<(K, V), 8>, IntoIter<K, V>>

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

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

§

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

§

impl<K, V> Freeze for SsoHashMap<K, V>
where K: Freeze, V: Freeze,

§

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

§

impl<K, V> Send for SsoHashMap<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for SsoHashMap<K, V>
where K: Sync, V: Sync,

§

impl<K, V> Unpin for SsoHashMap<K, V>
where K: Unpin, V: Unpin,

§

impl<K, V> UnwindSafe for SsoHashMap<K, V>
where K: UnwindSafe, V: 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> Filterable for T

source§

fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. Read more
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<P> IntoQueryParam<P> for P

source§

impl<T> MaybeResult<T> for T

source§

type Error = !

source§

fn from(_: Result<T, <T as MaybeResult<T>>::Error>) -> T

source§

fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>

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> 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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<Tcx, T> Value<Tcx> for T
where Tcx: DepContext,

source§

default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> 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,

source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T
where T: Send + Sync,

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.