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<U, F: Fn(T) -> bool>(self, f: F) -> bool
pub fn any<U, F: Fn(T) -> bool>(self, f: F) -> bool
pub fn filter<U, 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
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_small_vec<HCX, const LEN: usize>(
self,
hcx: &HCX
) -> SmallVec<[T; LEN]>where
T: ToStableHashKey<HCX>,
Trait Implementations§
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§
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> Erased for T
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.