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>
impl<T, I: Iterator<Item = T>> UnordItems<T, I>
pub fn map<U, F: Fn(T) -> U>( self, f: F, ) -> UnordItems<U, impl Iterator<Item = U>>
pub fn all<F: Fn(T) -> bool>(self, f: F) -> bool
pub fn any<F: Fn(T) -> bool>(self, f: F) -> bool
pub fn filter<F: Fn(&T) -> bool>( self, f: F, ) -> UnordItems<T, impl Iterator<Item = T>>
pub fn filter_map<U, F: Fn(T) -> Option<U>>( self, f: F, ) -> UnordItems<U, impl Iterator<Item = U>>
pub fn max(self) -> Option<T>where
T: Ord,
pub fn min(self) -> Option<T>where
T: Ord,
pub fn sum<S>(self) -> Swhere
S: Sum<T>,
pub fn product<S>(self) -> Swhere
S: Product<T>,
pub fn count(self) -> usize
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,
pub fn collect<C: From<UnordItems<T, I>>>(self) -> C
source§impl<'a, T: Clone + 'a, I: Iterator<Item = &'a T>> UnordItems<&'a T, I>
impl<'a, T: Clone + 'a, I: Iterator<Item = &'a T>> UnordItems<&'a T, I>
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>
impl<'a, T: Copy + 'a, I: Iterator<Item = &'a T>> UnordItems<&'a T, I>
pub fn copied(self) -> UnordItems<T, impl Iterator<Item = T>>
source§impl<T, I: Iterator<Item = T>> UnordItems<T, I>
impl<T, I: Iterator<Item = T>> UnordItems<T, I>
pub fn into_sorted<HCX>(self, hcx: &HCX) -> Vec<T>where
T: ToStableHashKey<HCX>,
pub fn into_sorted_stable_ord(self) -> Vec<T>where
T: StableCompare,
pub fn into_sorted_stable_ord_by_key<K, C>(self, project_to_key: C) -> Vec<T>
pub fn collect_sorted<HCX, C>(self, hcx: &HCX, cache_sort_key: bool) -> C
pub fn collect_stable_ord_by_key<K, C, P>(self, project_to_key: P) -> C
Trait Implementations§
source§impl<T: Clone, I: Clone + Iterator<Item = T>> Clone for UnordItems<T, I>
impl<T: Clone, I: Clone + Iterator<Item = T>> Clone for UnordItems<T, I>
source§fn clone(&self) -> UnordItems<T, I>
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<K: Hash + Eq, V, I: Iterator<Item = (K, V)>> From<UnordItems<(K, V), I>> for UnordMap<K, V>
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
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>
impl<T, I: Iterator<Item = T>> From<UnordItems<T, I>> for UnordBag<T>
source§fn from(value: UnordItems<T, I>) -> Self
fn from(value: UnordItems<T, I>) -> Self
Converts to this type from the input type.
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> 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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moresource§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
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.