rustc_data_structures::unord

Struct 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> DynSend for UnordItems<T, I>
where I: DynSend,

§

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

§

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 u8)

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