Trait LendingIterator

Source
pub trait LendingIterator {
    type Item<'a>
       where Self: 'a;

Show 37 methods // Required method fn next(&mut self) -> Option<Self::Item<'_>>; // Provided methods fn size_hint(&self) -> (usize, Option<usize>) { ... } fn count(self) -> usize where Self: Sized { ... } fn advance_by(&mut self, n: usize) -> Result<(), NonZeroUsize> { ... } fn nth(&mut self, n: usize) -> Option<Self::Item<'_>> { ... } fn step_by(self, step: usize) -> StepBy<Self> where Self: Sized { ... } fn take(self, n: usize) -> Take<Self> where Self: Sized { ... } fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where Self: Sized, P: for<'a> FnMut(&Self::Item<'a>) -> bool { ... } fn chain<I>(self, other: I) -> Chain<Self, I> where Self: Sized, for<'a> I: LendingIterator<Item<'a> = Self::Item<'a>> + 'a { ... } fn zip<I>(self, other: I) -> Zip<Self, I> where Self: Sized, I: LendingIterator { ... } fn map<F>(self, f: F) -> Map<Self, F> where Self: Sized, F: for<'a> SingleArgFnMut<Self::Item<'a>> { ... } fn for_each<F>(self, f: F) where Self: Sized, F: FnMut(Self::Item<'_>) { ... } fn filter<P>(self, predicate: P) -> Filter<Self, P> where Self: Sized, P: for<'a> FnMut(&Self::Item<'a>) -> bool { ... } fn filter_map<F>(self, f: F) -> FilterMap<Self, F> where Self: Sized, F: for<'a> SingleArgFnMut<Self::Item<'a>>, for<'a> <F as SingleArgFnOnce<Self::Item<'a>>>::Output: OptionTrait { ... } fn fold<B, F>(self, init: B, f: F) -> B where Self: Sized, F: FnMut(B, Self::Item<'_>) -> B { ... } fn cloned<T>(self) -> Cloned<Self> where Self: Sized, for<'a> Self::Item<'a>: Deref<Target = T>, T: Clone { ... } fn enumerate(self) -> Enumerate<Self> where Self: Sized { ... } fn skip(self, n: usize) -> Skip<Self> where Self: Sized { ... } fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where Self: Sized, P: for<'a> FnMut(&Self::Item<'a>) -> bool { ... } fn by_ref(&mut self) -> &mut Self where Self: Sized { ... } fn all<P>(&mut self, predicate: P) -> bool where P: FnMut(Self::Item<'_>) -> bool { ... } fn any<P>(&mut self, predicate: P) -> bool where P: FnMut(Self::Item<'_>) -> bool { ... } fn is_partitioned<P>(self, predicate: P) -> bool where Self: Sized, P: FnMut(Self::Item<'_>) -> bool { ... } fn find<P>(&mut self, predicate: P) -> Option<Self::Item<'_>> where P: FnMut(&Self::Item<'_>) -> bool { ... } fn find_map<B, F>(&mut self, f: F) -> Option<B> where F: FnMut(Self::Item<'_>) -> Option<B> { ... } fn position<P>(&mut self, predicate: P) -> Option<usize> where P: FnMut(Self::Item<'_>) -> bool { ... } fn cmp<I>(self, other: I) -> Ordering where I: for<'a> LendingIterator<Item<'a> = Self::Item<'a>>, for<'a> Self::Item<'a>: Ord, Self: Sized { ... } fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering where Self: Sized, I: LendingIterator, F: FnMut(Self::Item<'_>, I::Item<'_>) -> Ordering { ... } fn partial_cmp<I>(self, other: I) -> Option<Ordering> where I: LendingIterator, for<'a> Self::Item<'a>: PartialOrd<I::Item<'a>>, Self: Sized { ... } fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering> where Self: Sized, I: LendingIterator, F: FnMut(Self::Item<'_>, I::Item<'_>) -> Option<Ordering> { ... } fn eq<I>(self, other: I) -> bool where I: LendingIterator, for<'a> Self::Item<'a>: PartialEq<I::Item<'a>>, Self: Sized { ... } fn eq_by<I, F>(self, other: I, eq: F) -> bool where Self: Sized, I: LendingIterator, F: FnMut(Self::Item<'_>, I::Item<'_>) -> bool { ... } fn ne<I>(self, other: I) -> bool where I: LendingIterator, for<'a> Self::Item<'a>: PartialEq<I::Item<'a>>, Self: Sized { ... } fn lt<I>(self, other: I) -> bool where I: LendingIterator, for<'a> Self::Item<'a>: PartialOrd<I::Item<'a>>, Self: Sized { ... } fn le<I>(self, other: I) -> bool where I: LendingIterator, for<'a> Self::Item<'a>: PartialOrd<I::Item<'a>>, Self: Sized { ... } fn gt<I>(self, other: I) -> bool where I: LendingIterator, for<'a> Self::Item<'a>: PartialOrd<I::Item<'a>>, Self: Sized { ... } fn ge<I>(self, other: I) -> bool where I: LendingIterator, for<'a> Self::Item<'a>: PartialOrd<I::Item<'a>>, Self: Sized { ... }
}
Expand description

Like Iterator, but items may borrow from &mut self.

This means that the compiler will check that you finish using an item before requesting the next item, as it’s not allowed for two &mut self to exist at the same time.

Required Associated Types§

Source

type Item<'a> where Self: 'a

The type of the elements being iterated over.

Required Methods§

Source

fn next(&mut self) -> Option<Self::Item<'_>>

Advances the lending iterator and returns the next value.

See Iterator::next.

Provided Methods§

Source

fn size_hint(&self) -> (usize, Option<usize>)

Returns the bounds on the remaining length of the iterator.

See Iterator::size_hint.

Source

fn count(self) -> usize
where Self: Sized,

Returns the number of items in the lending iterator.

See Iterator::count.

Source

fn advance_by(&mut self, n: usize) -> Result<(), NonZeroUsize>

Advances the lending iterator by n elements.

See Iterator::advance_by.

Source

fn nth(&mut self, n: usize) -> Option<Self::Item<'_>>

Returns the nth element of the lending iterator.

See Iterator::nth.

Source

fn step_by(self, step: usize) -> StepBy<Self>
where Self: Sized,

Creates a lending iterator starting at the same point, but stepping by the given amount at each iteration.

See Iterator::step_by.

Source

fn take(self, n: usize) -> Take<Self>
where Self: Sized,

Creates a lending iterator that lends the first n elements, or fewer if the underlying iterator ends sooner.

See Iterator::take.

Source

fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
where Self: Sized, P: for<'a> FnMut(&Self::Item<'a>) -> bool,

Creates a lending iterator that lends items matching a predicate.

The predicate is called once for every item. Once it returns false once, None is returned for all subsequent calls to next.

Source

fn chain<I>(self, other: I) -> Chain<Self, I>
where Self: Sized, for<'a> I: LendingIterator<Item<'a> = Self::Item<'a>> + 'a,

Takes two lending iterators and creates a new lending iterator over both in sequence.

See Iterator::chain.

Source

fn zip<I>(self, other: I) -> Zip<Self, I>
where Self: Sized, I: LendingIterator,

‘Zips up’ two lending iterators into a single lending iterator of pairs.

Source

fn map<F>(self, f: F) -> Map<Self, F>
where Self: Sized, F: for<'a> SingleArgFnMut<Self::Item<'a>>,

Takes a closure and creates a lending iterator which calls that closure on each element.

As of writing, in stable rust it’s not possible to create a closure where the lifetime of its output is tied to its input. If you’re on nightly, you can use the unstable closure_lifetime_binder feature. If you’re on stable, try using a function.

In the case that the closure’s return type doesn’t borrow from its input, the resulting LendingIterator will implement IntoIterator.

See Iterator::map.

Source

fn for_each<F>(self, f: F)
where Self: Sized, F: FnMut(Self::Item<'_>),

Calls a closure on each element of the lending iterator.

See Iterator::for_each.

Source

fn filter<P>(self, predicate: P) -> Filter<Self, P>
where Self: Sized, P: for<'a> FnMut(&Self::Item<'a>) -> bool,

Creates a lending iterator which uses a closure to determine if an element should be yielded.

See Iterator::filter.

Source

fn filter_map<F>(self, f: F) -> FilterMap<Self, F>
where Self: Sized, F: for<'a> SingleArgFnMut<Self::Item<'a>>, for<'a> <F as SingleArgFnOnce<Self::Item<'a>>>::Output: OptionTrait,

Creates a lending iterator that both filters and maps.

See Iterator::filter_map.

Source

fn fold<B, F>(self, init: B, f: F) -> B
where Self: Sized, F: FnMut(B, Self::Item<'_>) -> B,

Folds every element into an accumulator by applying an operation, returning the final result.

See Iterator::fold.

Source

fn cloned<T>(self) -> Cloned<Self>
where Self: Sized, for<'a> Self::Item<'a>: Deref<Target = T>, T: Clone,

Creates a lending iterator which clones all of its elements.

The resulting lending iterator implements IntoIterator.

See Iterator::cloned.

Source

fn enumerate(self) -> Enumerate<Self>
where Self: Sized,

Creates a lending iterator which gives the current iteration count as well as the next value.

Source

fn skip(self, n: usize) -> Skip<Self>
where Self: Sized,

Creates a lending iterator that skips over the first n elements of self.

Source

fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
where Self: Sized, P: for<'a> FnMut(&Self::Item<'a>) -> bool,

Creates a lending iterator that rejects elements while predicate returns true.

Source

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Borrows the lending iterator.

This is useful to allow applying iterator adapters while still retaining ownership of the original iterator.

Unfortunately adapters that take in a closure are currently incompatible with this, due to limitations in the borrow checker.

Source

fn all<P>(&mut self, predicate: P) -> bool
where P: FnMut(Self::Item<'_>) -> bool,

Tests if every element of the iterator matches a predicate.

Source

fn any<P>(&mut self, predicate: P) -> bool
where P: FnMut(Self::Item<'_>) -> bool,

Tests if any element of the iterator matches a predicate.

Source

fn is_partitioned<P>(self, predicate: P) -> bool
where Self: Sized, P: FnMut(Self::Item<'_>) -> bool,

Checks if the elements of this iterator are partitioned according to the given predicate, such that all those that return true precede all those that return false.

Source

fn find<P>(&mut self, predicate: P) -> Option<Self::Item<'_>>
where P: FnMut(&Self::Item<'_>) -> bool,

Searches for an element of an iterator that satisfies a predicate.

Source

fn find_map<B, F>(&mut self, f: F) -> Option<B>
where F: FnMut(Self::Item<'_>) -> Option<B>,

Applies function to the elements of iterator and returns the first non-none result.

Source

fn position<P>(&mut self, predicate: P) -> Option<usize>
where P: FnMut(Self::Item<'_>) -> bool,

Searches for an element in an iterator, returning its index.

Source

fn cmp<I>(self, other: I) -> Ordering
where I: for<'a> LendingIterator<Item<'a> = Self::Item<'a>>, for<'a> Self::Item<'a>: Ord, Self: Sized,

Lexicographically compares the elements of this Iterator with those of another.

Source

fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering
where Self: Sized, I: LendingIterator, F: FnMut(Self::Item<'_>, I::Item<'_>) -> Ordering,

Lexicographically compares the elements of this Iterator with those of another with respect to the specified comparison function.

Source

fn partial_cmp<I>(self, other: I) -> Option<Ordering>
where I: LendingIterator, for<'a> Self::Item<'a>: PartialOrd<I::Item<'a>>, Self: Sized,

Lexicographically compares the PartialOrd elements of this Iterator with those of another. The comparison works like short-circuit evaluation, returning a result without comparing the remaining elements. As soon as an order can be determined, the evaluation stops and a result is returned.

Source

fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>
where Self: Sized, I: LendingIterator, F: FnMut(Self::Item<'_>, I::Item<'_>) -> Option<Ordering>,

Lexicographically compares the elements of this Iterator with those of another with respect to the specified comparison function.

Source

fn eq<I>(self, other: I) -> bool
where I: LendingIterator, for<'a> Self::Item<'a>: PartialEq<I::Item<'a>>, Self: Sized,

Determines if the elements of this Iterator are equal to those of another.

Source

fn eq_by<I, F>(self, other: I, eq: F) -> bool
where Self: Sized, I: LendingIterator, F: FnMut(Self::Item<'_>, I::Item<'_>) -> bool,

Determines if the elements of this Iterator are equal to those of another with respect to the specified equality function.

Source

fn ne<I>(self, other: I) -> bool
where I: LendingIterator, for<'a> Self::Item<'a>: PartialEq<I::Item<'a>>, Self: Sized,

Determines if the elements of this Iterator are not equal to those of another.

Source

fn lt<I>(self, other: I) -> bool
where I: LendingIterator, for<'a> Self::Item<'a>: PartialOrd<I::Item<'a>>, Self: Sized,

Determines if the elements of this Iterator are lexicographically less than those of another.

Source

fn le<I>(self, other: I) -> bool
where I: LendingIterator, for<'a> Self::Item<'a>: PartialOrd<I::Item<'a>>, Self: Sized,

Determines if the elements of this Iterator are lexicographically less or equal to those of another.

Source

fn gt<I>(self, other: I) -> bool
where I: LendingIterator, for<'a> Self::Item<'a>: PartialOrd<I::Item<'a>>, Self: Sized,

Determines if the elements of this Iterator are lexicographically greater than those of another.

Source

fn ge<I>(self, other: I) -> bool
where I: LendingIterator, for<'a> Self::Item<'a>: PartialOrd<I::Item<'a>>, Self: Sized,

Determines if the elements of this Iterator are lexicographically greater or equal to those of another.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T: LendingIterator> LendingIterator for &mut T

Source§

type Item<'a> = <T as LendingIterator>::Item<'a> where Self: 'a

Source§

fn next(&mut self) -> Option<Self::Item<'_>>

Source§

fn size_hint(&self) -> (usize, Option<usize>)

Implementors§

Source§

impl<A, B> LendingIterator for Chain<A, B>
where A: LendingIterator, for<'a> B: LendingIterator<Item<'a> = A::Item<'a>> + 'a,

Source§

type Item<'a> = <A as LendingIterator>::Item<'a> where Self: 'a

Source§

impl<A, B> LendingIterator for Zip<A, B>

Source§

type Item<'a> = (<A as LendingIterator>::Item<'a>, <B as LendingIterator>::Item<'a>) where A: 'a, B: 'a

Source§

impl<I> LendingIterator for Cloned<I>
where I: LendingIterator, for<'a> I::Item<'a>: Deref, for<'a> <I::Item<'a> as Deref>::Target: Clone,

Source§

type Item<'a> = <<I as LendingIterator>::Item<'a> as Deref>::Target where Self: 'a

Source§

impl<I> LendingIterator for LendRefs<I>
where I: Iterator,

Source§

type Item<'a> = &'a <I as Iterator>::Item where Self: 'a

Source§

impl<I> LendingIterator for Skip<I>
where I: LendingIterator,

Source§

type Item<'a> = <I as LendingIterator>::Item<'a> where I: 'a

Source§

impl<I> LendingIterator for StepBy<I>
where I: LendingIterator,

Source§

type Item<'a> = <I as LendingIterator>::Item<'a> where Self: 'a

Source§

impl<I> LendingIterator for Take<I>
where I: LendingIterator,

Source§

type Item<'a> = <I as LendingIterator>::Item<'a> where I: 'a

Source§

impl<I, F> LendingIterator for FilterMap<I, F>
where I: LendingIterator, F: for<'a> SingleArgFnMut<I::Item<'a>>, for<'a> <F as SingleArgFnOnce<I::Item<'a>>>::Output: OptionTrait,

Source§

type Item<'a> = <<F as SingleArgFnOnce<<I as LendingIterator>::Item<'a>>>::Output as OptionTrait>::Item where Self: 'a

Source§

impl<I, F> LendingIterator for Map<I, F>
where I: LendingIterator, F: for<'a> SingleArgFnMut<I::Item<'a>>,

Source§

type Item<'a> = <F as SingleArgFnOnce<<I as LendingIterator>::Item<'a>>>::Output where Self: 'a

Source§

impl<I, P> LendingIterator for Filter<I, P>
where I: LendingIterator, P: for<'a> FnMut(&I::Item<'a>) -> bool,

Source§

type Item<'a> = <I as LendingIterator>::Item<'a> where Self: 'a

Source§

impl<I, P> LendingIterator for SkipWhile<I, P>
where I: LendingIterator, P: for<'a> FnMut(&I::Item<'a>) -> bool,

Source§

type Item<'a> = <I as LendingIterator>::Item<'a> where Self: 'a

Source§

impl<I, P> LendingIterator for TakeWhile<I, P>
where I: LendingIterator, P: for<'a> FnMut(&I::Item<'a>) -> bool,

Source§

type Item<'a> = <I as LendingIterator>::Item<'a> where I: 'a, P: 'a

Source§

impl<I: Iterator> LendingIterator for IntoLending<I>

Source§

type Item<'a> = <I as Iterator>::Item where Self: 'a

Source§

impl<I: Iterator> LendingIterator for LendRefsMut<I>

Source§

type Item<'a> = &'a mut <I as Iterator>::Item where Self: 'a

Source§

impl<I: Iterator> LendingIterator for Windows<I>

Source§

type Item<'a> = &'a [<I as Iterator>::Item] where Self: 'a

Source§

impl<I: Iterator> LendingIterator for WindowsMut<I>

Source§

type Item<'a> = &'a mut [<I as Iterator>::Item] where Self: 'a

Source§

impl<I: LendingIterator> LendingIterator for Enumerate<I>

Source§

type Item<'a> = (usize, <I as LendingIterator>::Item<'a>) where Self: 'a