Trait gat_lending_iterator::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.

Object Safety§

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