pub trait Sequence {
type Item;
type Iter: Iterator<Item = Self::Item>;
// Required method
fn into_iter(self) -> Self::Iter;
// Provided methods
fn collect_array<const N: usize>(self) -> [Self::Item; N]
where Self: Sized + ConstMinLen<N> { ... }
fn map<F, B>(self, f: F) -> Map<Self, F>
where Self: Sized,
F: FnMut(Self::Item) -> B { ... }
fn enumerate(self) -> Enumerate<Self>
where Self: Sized { ... }
fn const_take_exact<const N: usize>(self) -> ConstTakeExact<Self, N>
where Self: Sized + ConstMinLen<N> { ... }
}Expand description
Represents a stateless abstract sequence of values.
This trait closely resembles Iterator in terms of functionality but unlike
the latter, it cannot yield its elements directly. Instead, it must first be
irreversibly converted into an iterator using into_iter.
This design allows a Sequence to encode additional invariants, such as a
constant size, which is not possible with standard iterators.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn collect_array<const N: usize>(self) -> [Self::Item; N]where
Self: Sized + ConstMinLen<N>,
fn collect_array<const N: usize>(self) -> [Self::Item; N]where
Self: Sized + ConstMinLen<N>,
Collects this sequence’s elements into an array.
Sourcefn map<F, B>(self, f: F) -> Map<Self, F>
fn map<F, B>(self, f: F) -> Map<Self, F>
Returns a new sequence that transforms every element of the original
sequence using f.
Sourcefn enumerate(self) -> Enumerate<Self>where
Self: Sized,
fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
Returns a new sequence that yields the current iteration index together with every element.
Sourcefn const_take_exact<const N: usize>(self) -> ConstTakeExact<Self, N>where
Self: Sized + ConstMinLen<N>,
fn const_take_exact<const N: usize>(self) -> ConstTakeExact<Self, N>where
Self: Sized + ConstMinLen<N>,
Returns a new sequence that yields exactly N first elements of the original sequence.