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: Ord, I: Iterator<Item = T>> UnordItems<T, I>
impl<T: Ord, 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: Ord + StableOrd,
pub fn into_sorted_small_vec<HCX, const LEN: usize>( self, hcx: &HCX ) -> SmallVec<[T; LEN]>where T: ToStableHashKey<HCX>,
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> 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
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.