Struct Take
#[must_use = "iterators are lazy and do nothing unless consumed"]
pub struct Take<I> { pub(in ::iter::adapters::take) iter: I, pub(in ::iter::adapters::take) n: usize }
An iterator that only iterates over the first n iterations of iter.
This struct is created by the take method on Iterator. See its
documentation for more.
Fields
iter: In: usize
Implementations
impl<I> Take<I>
const fn new(iter: I, n: usize) -> Take<I>
Trait Implementations
impl<F: FnMut() -> A, A> ExactSizeIterator for Take<RepeatWith<F>>
fn len(&self) -> usize
impl<I> DoubleEndedIterator for Take<I>
where
I: DoubleEndedIterator + ExactSizeIterator,
fn next_back(&mut self) -> Option<Self::Item>fn nth_back(&mut self, n: usize) -> Option<Self::Item>fn try_rfold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R where Self: Sized, Fold: FnMut(Acc, Self::Item) -> R, R: Try<Output = Acc>,fn rfold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc where Self: Sized, Fold: FnMut(Acc, Self::Item) -> Acc,fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>>
impl<I> ExactSizeIterator for Take<I>
where
I: ExactSizeIterator,
impl<I> FusedIterator for Take<I>
where
I: FusedIterator,
impl<I> Iterator for Take<I>
where
I: Iterator,
type Item = <I as Iterator>::Item;fn next(&mut self) -> Option<<I as Iterator>::Item>fn nth(&mut self, n: usize) -> Option<I::Item>fn count(self) -> usizefn size_hint(&self) -> (usize, Option<usize>)fn try_fold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R where Fold: FnMut(Acc, Self::Item) -> R, R: Try<Output = Acc>,fn fold<B, F>(self, init: B, f: F) -> B where Self: Sized, F: FnMut(B, Self::Item) -> B,fn for_each<F: FnMut(Self::Item)>(self, f: F)fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>>
impl<I> SourceIter for Take<I>
where
I: SourceIter,
type Source = <I as SourceIter>::Source;unsafe fn as_inner(&mut self) -> &mut I::Source
impl<I: Clone> Clone for Take<I>
fn clone(&self) -> Take<I>
impl<I: Debug> Debug for Take<I>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<I: InPlaceIterable> InPlaceIterable for Take<I>
const EXPAND_BY: Option<NonZero<usize>> = I::EXPAND_BY;const MERGE_BY: Option<NonZero<usize>> = I::MERGE_BY;
impl<I: Iterator + TrustedRandomAccess> SpecTake for Take<I>
fn spec_fold<B, F>(self, init: B, f: F) -> B where Self: Sized, F: FnMut(B, Self::Item) -> B,fn spec_for_each<F: FnMut(Self::Item)>(self, f: F)
impl<I: Iterator> SpecTake for Take<I>
fn spec_fold<B, F>(self, init: B, f: F) -> B where Self: Sized, F: FnMut(B, Self::Item) -> B,fn spec_for_each<F: FnMut(Self::Item)>(self, f: F)
impl<I: TrustedFused> TrustedFused for Take<I>
impl<I: TrustedLen> TrustedLen for Take<I>
impl<T: Clone> DoubleEndedIterator for Take<Repeat<T>>
fn next_back(&mut self) -> Option<Self::Item>fn nth_back(&mut self, n: usize) -> Option<Self::Item>fn try_rfold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R where Self: Sized, Fold: FnMut(Acc, Self::Item) -> R, R: Try<Output = Acc>,fn rfold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc where Self: Sized, Fold: FnMut(Acc, Self::Item) -> Acc,fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>>
impl<T: Clone> ExactSizeIterator for Take<Repeat<T>>
fn len(&self) -> usize
Auto Trait Implementations
impl<I> Freeze for Take<I>
where
I: Freeze,
impl<I> RefUnwindSafe for Take<I>
where
I: RefUnwindSafe,
impl<I> Send for Take<I>
where
I: Send,
impl<I> Sync for Take<I>
where
I: Sync,
impl<I> Unpin for Take<I>
where
I: Unpin,
impl<I> UnsafeUnpin for Take<I>
where
I: UnsafeUnpin,
impl<I> UnwindSafe for Take<I>
where
I: UnwindSafe,
Blanket Implementations
impl<I> IntoIterator for Take<I>
where
I: Iterator,
type Item = <I as Iterator>::Item;type IntoIter = I;fn into_iter(self) -> I
impl<T> Any for Take<I>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Take<I>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Take<I>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Take<I>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Take<I>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> SizeHint for Take<I>
where
T: ?Sized,
fn lower_bound(&self) -> usizefn upper_bound(&self) -> Option<usize>
impl<T> SizedTypeProperties for Take<I>
impl<T, U> Into<U> for Take<I>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Take<I>
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for Take<I>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>