Struct rustc_data_structures::unord::UnordItems

source ·
pub struct UnordItems<T, I: Iterator<Item = T>>(I);
Expand description

UnordItems is the order-less version of Iterator. It only contains methods that don’t (easily) expose an ordering of the underlying items.

Most methods take an Fn where the Iterator-version takes an FnMut. This is to reduce the risk of accidentally leaking the internal order via the closure environment. Otherwise one could easily do something like

let mut ordered = vec![];
unordered_items.all(|x| ordered.push(x));

It’s still possible to do the same thing with an Fn by using interior mutability, but the chance of doing it accidentally is reduced.

Tuple Fields§

§0: I

Implementations§

source§

impl<T, I: Iterator<Item = T>> UnordItems<T, I>

source

pub fn map<U, F: Fn(T) -> U>( self, f: F, ) -> UnordItems<U, impl Iterator<Item = U>>

source

pub fn all<F: Fn(T) -> bool>(self, f: F) -> bool

source

pub fn any<F: Fn(T) -> bool>(self, f: F) -> bool

source

pub fn filter<F: Fn(&T) -> bool>( self, f: F, ) -> UnordItems<T, impl Iterator<Item = T>>

source

pub fn filter_map<U, F: Fn(T) -> Option<U>>( self, f: F, ) -> UnordItems<U, impl Iterator<Item = U>>

source

pub fn max(self) -> Option<T>
where T: Ord,

source

pub fn min(self) -> Option<T>
where T: Ord,

source

pub fn sum<S>(self) -> S
where S: Sum<T>,

source

pub fn product<S>(self) -> S
where S: Product<T>,

source

pub fn count(self) -> usize

source

pub fn flat_map<U, F, O>(self, f: F) -> UnordItems<O, impl Iterator<Item = O>>
where U: IntoIterator<Item = O>, F: Fn(T) -> U,

source

pub fn collect<C: From<UnordItems<T, I>>>(self) -> C

source§

impl<T> UnordItems<T, Empty<T>>

source

pub fn empty() -> Self

source§

impl<'a, T: Clone + 'a, I: Iterator<Item = &'a T>> UnordItems<&'a T, I>

source

pub fn cloned(self) -> UnordItems<T, impl Iterator<Item = T>>

source§

impl<'a, T: Copy + 'a, I: Iterator<Item = &'a T>> UnordItems<&'a T, I>

source

pub fn copied(self) -> UnordItems<T, impl Iterator<Item = T>>

source§

impl<T, I: Iterator<Item = T>> UnordItems<T, I>

source

pub fn into_sorted<HCX>(self, hcx: &HCX) -> Vec<T>
where T: ToStableHashKey<HCX>,

source

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

source

pub fn into_sorted_stable_ord_by_key<K, C>(self, project_to_key: C) -> Vec<T>
where K: StableCompare, C: for<'a> Fn(&'a T) -> &'a K,

source

pub fn collect_sorted<HCX, C>(self, hcx: &HCX, cache_sort_key: bool) -> C
where T: ToStableHashKey<HCX>, C: FromIterator<T> + BorrowMut<[T]>,

source

pub fn collect_stable_ord_by_key<K, C, P>(self, project_to_key: P) -> C
where K: StableCompare, P: for<'a> Fn(&'a T) -> &'a K, C: FromIterator<T> + BorrowMut<[T]>,

Trait Implementations§

source§

impl<T: Clone, I: Clone + Iterator<Item = T>> Clone for UnordItems<T, I>

source§

fn clone(&self) -> UnordItems<T, I>

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: 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<T, I: Iterator<Item = T>> From<UnordItems<T, I>> for UnordBag<T>

source§

fn from(value: UnordItems<T, I>) -> 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<T, I> !IntoIterator for UnordItems<T, I>

Auto Trait Implementations§

§

impl<T, I> Freeze for UnordItems<T, I>
where I: Freeze,

§

impl<T, I> RefUnwindSafe for UnordItems<T, I>
where I: RefUnwindSafe,

§

impl<T, I> Send for UnordItems<T, I>
where I: Send,

§

impl<T, I> Sync for UnordItems<T, I>
where I: Sync,

§

impl<T, I> Unpin for UnordItems<T, I>
where I: Unpin,

§

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