Lender

Trait Lender 

Source
pub trait Lender: for<'all> Lending<'all> {
Show 79 methods // Required method fn next(&mut self) -> Option<Lend<'_, Self>>; // Provided methods fn next_chunk(&mut self, chunk_size: usize) -> Chunk<'_, Self> where Self: Sized { ... } fn size_hint(&self) -> (usize, Option<usize>) { ... } fn count(self) -> usize where Self: Sized { ... } fn last<'call>(&'call mut self) -> Option<Lend<'call, Self>> where Self: Sized { ... } fn advance_by(&mut self, n: usize) -> Result<(), NonZeroUsize> { ... } fn nth(&mut self, n: usize) -> Option<Lend<'_, Self>> { ... } fn step_by(self, step: usize) -> StepBy<Self> where Self: Sized { ... } fn chain<U>(self, other: U) -> Chain<Self, <U as IntoLender>::Lender> where Self: Sized, for<'all> U: IntoLender + Lending<'all, Lend = Lend<'all, Self>> { ... } fn zip<U: IntoLender>( self, other: U, ) -> Zip<Self, <U as IntoLender>::Lender> where Self: Sized { ... } fn intersperse<'call>( self, separator: Lend<'call, Self>, ) -> Intersperse<'call, Self> where Self: Sized, for<'all> Lend<'all, Self>: Clone { ... } fn intersperse_with<'call, G>( self, separator: G, ) -> IntersperseWith<'call, Self, G> where Self: Sized, G: FnMut() -> Lend<'call, Self> { ... } fn map<F>(self, f: F) -> Map<Self, F> where Self: Sized, F: for<'all> FnMutHKA<'all, Lend<'all, Self>> { ... } fn map_into_iter<O, F: FnMut(Lend<'_, Self>) -> O>( self, f: F, ) -> MapIntoIter<Self, O, F> where Self: Sized { ... } fn for_each<F>(self, f: F) where Self: Sized, F: FnMut(Lend<'_, Self>) { ... } fn filter<P>(self, predicate: P) -> Filter<Self, P> where Self: Sized, P: FnMut(&Lend<'_, Self>) -> bool { ... } fn filter_map<F>(self, f: F) -> FilterMap<Self, F> where Self: Sized, F: for<'all> FnMutHKAOpt<'all, Lend<'all, Self>> { ... } fn enumerate(self) -> Enumerate<Self> where Self: Sized { ... } fn peekable<'call>(self) -> Peekable<'call, Self> where Self: Sized { ... } fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where Self: Sized, P: FnMut(&Lend<'_, Self>) -> bool { ... } fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where Self: Sized, P: FnMut(&Lend<'_, Self>) -> bool { ... } fn map_while<P>(self, predicate: P) -> MapWhile<Self, P> where Self: Sized, P: for<'all> FnMutHKAOpt<'all, Lend<'all, Self>> { ... } fn skip(self, n: usize) -> Skip<Self> where Self: Sized { ... } fn take(self, n: usize) -> Take<Self> where Self: Sized { ... } fn scan<St, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> where Self: Sized, F: for<'all> FnMutHKAOpt<'all, (&'all mut St, Lend<'all, Self>)> { ... } fn flat_map<'call, F>(self, f: F) -> FlatMap<'call, Self, F> where Self: Sized, F: for<'all> FnMutHKA<'all, Lend<'all, Self>>, for<'all> <F as FnMutHKA<'all, Lend<'all, Self>>>::B: IntoLender { ... } fn flatten<'call>(self) -> Flatten<'call, Self> where Self: Sized, for<'all> Lend<'all, Self>: IntoLender { ... } fn fuse(self) -> Fuse<Self> where Self: Sized { ... } fn inspect<F>(self, f: F) -> Inspect<Self, F> where Self: Sized, F: FnMut(&Lend<'_, Self>) { ... } fn mutate<F>(self, f: F) -> Mutate<Self, F> where Self: Sized, F: FnMut(&mut Lend<'_, Self>) { ... } fn by_ref(&mut self) -> &mut Self where Self: Sized { ... } fn collect<B>(self) -> B where Self: Sized, B: FromLender<Self> { ... } fn try_collect<'a, B>(&'a mut self) -> ChangeOutputType<Lend<'a, Self>, B> where Self: Sized, for<'all> Lend<'all, Self>: Try, for<'all> <Lend<'all, Self> as Try>::Residual: Residual<B>, for<'all> B: FromLender<TryShunt<'all, &'a mut Self>> { ... } fn collect_into<E>(self, collection: &mut E) -> &mut E where Self: Sized, E: ExtendLender<Self> { ... } fn partition<A, E, F>(self, f: F) -> (E, E) where Self: Sized, E: Default + ExtendLender<Self>, F: FnMut(&Lend<'_, Self>) -> bool { ... } fn is_partitioned<P>(self, predicate: P) -> bool where Self: Sized, P: FnMut(Lend<'_, Self>) -> bool { ... } fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R where Self: Sized, F: FnMut(B, Lend<'_, Self>) -> R, R: Try<Output = B> { ... } fn try_for_each<F, R>(&mut self, f: F) -> R where Self: Sized, F: FnMut(Lend<'_, Self>) -> R, R: Try<Output = ()> { ... } fn fold<B, F>(self, init: B, f: F) -> B where Self: Sized, F: FnMut(B, Lend<'_, Self>) -> B { ... } fn reduce<T, F>(self, f: F) -> Option<T> where Self: Sized, for<'all> Lend<'all, Self>: ToOwned<Owned = T>, F: FnMut(T, Lend<'_, Self>) -> T { ... } fn try_reduce<T, F, R>(self, f: F) -> ChangeOutputType<R, Option<T>> where Self: Sized, for<'all> Lend<'all, Self>: ToOwned<Owned = T>, F: FnMut(T, Lend<'_, Self>) -> R, R: Try<Output = T>, R::Residual: Residual<Option<T>> { ... } fn all<F>(&mut self, f: F) -> bool where Self: Sized, F: FnMut(Lend<'_, Self>) -> bool { ... } fn any<F>(&mut self, f: F) -> bool where Self: Sized, F: FnMut(Lend<'_, Self>) -> bool { ... } fn find<P>(&mut self, predicate: P) -> Option<Lend<'_, Self>> where Self: Sized, P: FnMut(&Lend<'_, Self>) -> bool { ... } fn find_map<'a, F>( &'a mut self, f: F, ) -> Option<<F as FnMutHKAOpt<'a, Lend<'a, Self>>>::B> where Self: Sized, F: for<'all> FnMutHKAOpt<'all, Lend<'all, Self>> { ... } fn try_find<F, R>( &mut self, f: F, ) -> ChangeOutputType<R, Option<Lend<'_, Self>>> where Self: Sized, F: FnMut(&Lend<'_, Self>) -> R, R: Try<Output = bool>, for<'all> R::Residual: Residual<Option<Lend<'all, Self>>> { ... } fn position<P>(&mut self, predicate: P) -> Option<usize> where Self: Sized, P: FnMut(Lend<'_, Self>) -> bool { ... } fn rposition<P>(&mut self, predicate: P) -> Option<usize> where P: FnMut(Lend<'_, Self>) -> bool, Self: Sized + ExactSizeLender + DoubleEndedLender { ... } fn max<T>(self) -> Option<T> where Self: Sized, T: for<'all> PartialOrd<Lend<'all, Self>>, for<'all> Lend<'all, Self>: ToOwned<Owned = T> { ... } fn min<T>(self) -> Option<T> where Self: Sized, T: for<'all> PartialOrd<Lend<'all, Self>>, for<'all> Lend<'all, Self>: ToOwned<Owned = T> { ... } fn max_by_key<B: Ord, T, F>(self, f: F) -> Option<T> where Self: Sized, for<'all> Lend<'all, Self>: ToOwned<Owned = T>, F: FnMut(&T) -> B { ... } fn max_by<T, F>(self, compare: F) -> Option<T> where Self: Sized, for<'all> Lend<'all, Self>: ToOwned<Owned = T>, F: FnMut(&T, &Lend<'_, Self>) -> Ordering { ... } fn min_by_key<B: Ord, T, F>(self, f: F) -> Option<T> where Self: Sized, for<'all> Lend<'all, Self>: ToOwned<Owned = T>, F: FnMut(&T) -> B { ... } fn min_by<T, F>(self, compare: F) -> Option<T> where Self: Sized, for<'all> Lend<'all, Self>: ToOwned<Owned = T>, F: FnMut(&T, &Lend<'_, Self>) -> Ordering { ... } fn rev(self) -> Rev<Self> where Self: Sized + DoubleEndedLender { ... } fn unzip<ExtA, ExtB>(self) -> (ExtA, ExtB) where Self: Sized, for<'all> Lend<'all, Self>: TupleLend<'all>, ExtA: Default + ExtendLender<FirstShunt<Self>>, ExtB: Default + ExtendLender<SecondShunt<Self>> { ... } fn copied<T>(self) -> Copied<Self> where Self: Sized + for<'all> Lending<'all, Lend = &'all T>, T: Copy { ... } fn cloned<T>(self) -> Cloned<Self> where Self: Sized + for<'all> Lending<'all, Lend = &'all T>, T: Clone { ... } fn owned(self) -> Owned<Self> where Self: Sized, for<'all> Lend<'all, Self>: ToOwned { ... } fn cycle(self) -> Cycle<Self> where Self: Sized + Clone { ... } fn sum<S>(self) -> S where Self: Sized, S: SumLender<Self> { ... } fn product<P>(self) -> P where Self: Sized, P: ProductLender<Self> { ... } fn cmp<L>(self, other: L) -> Ordering where L: IntoLender, L::Lender: for<'all> Lending<'all, Lend = Lend<'all, Self>>, for<'all> Lend<'all, Self>: Ord, Self: Sized { ... } fn cmp_by<L, F>(self, other: L, cmp: F) -> Ordering where Self: Sized, L: IntoLender, F: for<'all> FnMut(Lend<'all, Self>, Lend<'all, L::Lender>) -> Ordering { ... } fn partial_cmp<L>(self, other: L) -> Option<Ordering> where L: IntoLender, for<'all> Lend<'all, Self>: PartialOrd<Lend<'all, L::Lender>>, Self: Sized { ... } fn partial_cmp_by<L, F>(self, other: L, partial_cmp: F) -> Option<Ordering> where Self: Sized, L: IntoLender, F: for<'all> FnMut(Lend<'all, Self>, Lend<'all, L::Lender>) -> Option<Ordering> { ... } fn eq<L>(self, other: L) -> bool where L: IntoLender, for<'all> Lend<'all, Self>: PartialEq<Lend<'all, L::Lender>>, Self: Sized { ... } fn eq_by<L, F>(self, other: L, eq: F) -> bool where Self: Sized, L: IntoLender, F: for<'all> FnMut(Lend<'all, Self>, Lend<'all, L::Lender>) -> bool { ... } fn ne<L>(self, other: L) -> bool where L: IntoLender, for<'all> Lend<'all, Self>: PartialEq<Lend<'all, L::Lender>>, Self: Sized { ... } fn lt<L>(self, other: L) -> bool where L: IntoLender, for<'all> Lend<'all, Self>: PartialOrd<Lend<'all, L::Lender>>, Self: Sized { ... } fn le<L>(self, other: L) -> bool where L: IntoLender, for<'all> Lend<'all, Self>: PartialOrd<Lend<'all, L::Lender>>, Self: Sized { ... } fn gt<L>(self, other: L) -> bool where L: IntoLender, for<'all> Lend<'all, Self>: PartialOrd<Lend<'all, L::Lender>>, Self: Sized { ... } fn ge<L>(self, other: L) -> bool where L: IntoLender, for<'all> Lend<'all, Self>: PartialOrd<Lend<'all, L::Lender>>, Self: Sized { ... } fn is_sorted<T>(self) -> bool where Self: Sized, for<'all> Lend<'all, Self>: ToOwned<Owned = T>, T: PartialOrd { ... } fn is_sorted_by<T, F>(self, compare: F) -> bool where Self: Sized, for<'all> Lend<'all, Self>: ToOwned<Owned = T>, F: FnMut(&T, &T) -> Option<Ordering> { ... } fn is_sorted_by_key<F, K>(self, f: F) -> bool where Self: Sized, F: FnMut(Lend<'_, Self>) -> K, K: PartialOrd { ... } fn iter<'this>(self) -> Iter<'this, Self> where Self: Sized + 'this, for<'all> Lend<'all, Self>: 'this { ... } fn chunky(self, chunk_size: usize) -> Chunky<Self> where Self: Sized + ExactSizeLender { ... } fn into_fallible<E>(self) -> IntoFallible<E, Self> where Self: Sized { ... }
}
Expand description

A trait for dealing with lending iterators.

This is the main lender trait. For more about the concept of lenders generally, please see the crate documentation.

For more about the concept of iterators generally, please see core::iter.

Required Methods§

Source

fn next(&mut self) -> Option<Lend<'_, Self>>

Yield the next lend, if any, of the lender.

Every lend is only guaranteed to be valid one at a time for any kind of lender.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1, 2, 3u8].iter());
assert_eq!(lender.next(), Some(&1));
assert_eq!(lender.next(), Some(&2));
assert_eq!(lender.next(), Some(&3));
assert_eq!(lender.next(), None);

Provided Methods§

Source

fn next_chunk(&mut self, chunk_size: usize) -> Chunk<'_, Self>
where Self: Sized,

Take the next len lends of the lender with temporary lender Chunk. This is equivalent to cloning the lender and calling take(len) on it.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1, 2, 3u8].iter());
let mut chunk_lender = lender.next_chunk(2);
assert_eq!(chunk_lender.next(), Some(&1));
assert_eq!(chunk_lender.next(), Some(&2));
assert_eq!(chunk_lender.next(), None);
Source

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

Get the estimated minimum and maximum length of the lender. Use .len() for the exact length if the lender implements ExactSizeLender.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1, 2, 3u8].iter());
assert_eq!(lender.size_hint(), (3, Some(3)));
Source

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

Count the number of lends in the lender by consuming it.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1, 2, 3u8].iter());
assert_eq!(lender.count(), 3);
Source

fn last<'call>(&'call mut self) -> Option<Lend<'call, Self>>
where Self: Sized,

Get the last lend of the lender, if any, by consuming it.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1, 2, 3u8].iter());
assert_eq!(lender.last(), Some(&3));
Source

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

Advance the lender by n lends. If the lender does not have enough lends, return the number of lends left.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1, 2, 3u8].iter());
assert_eq!(lender.advance_by(2), Ok(()));
assert_eq!(lender.next(), Some(&3));
Source

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

Yield the nth lend of the lender, if any, by consuming it. If the lender does not have enough lends, returns None.

n is zero-indexed.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1, 2, 3u8].iter());
assert_eq!(lender.nth(2), Some(&3));
Source

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

Skip step - 1 lends between each lend of the lender.

§Panics

Panics if step is zero.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1, 2, 3, 4, 5, 6, 7, 8, 9, 10].iter());
let mut step_lender = lender.step_by(2);
assert_eq!(step_lender.next(), Some(&1));
assert_eq!(step_lender.next(), Some(&3));
assert_eq!(step_lender.next(), Some(&5));
assert_eq!(step_lender.next(), Some(&7));
assert_eq!(step_lender.next(), Some(&9));
assert_eq!(step_lender.next(), None);
Source

fn chain<U>(self, other: U) -> Chain<Self, <U as IntoLender>::Lender>
where Self: Sized, for<'all> U: IntoLender + Lending<'all, Lend = Lend<'all, Self>>,

Chain the lender with another lender of the same type.

The resulting lender will first yield all lends from self, then all lends from other.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1, 2].iter());
let mut other = lender::lend_iter::<lend!(&'lend u8), _>([3, 4].iter());
let mut chained = lender.chain(other);
assert_eq!(chained.next(), Some(&1));
assert_eq!(chained.next(), Some(&2));
assert_eq!(chained.next(), Some(&3));
assert_eq!(chained.next(), Some(&4));
assert_eq!(chained.next(), None);
Source

fn zip<U: IntoLender>(self, other: U) -> Zip<Self, <U as IntoLender>::Lender>
where Self: Sized,

Zip the lender with another lender of the same or different type.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1, 2].iter());
let mut other = lender::lend_iter::<lend!(&'lend u8), _>([3, 4].iter());
let mut zipped = lender.zip(other);
assert_eq!(zipped.next(), Some((&1, &3)));
assert_eq!(zipped.next(), Some((&2, &4)));
assert_eq!(zipped.next(), None);
Source

fn intersperse<'call>( self, separator: Lend<'call, Self>, ) -> Intersperse<'call, Self>
where Self: Sized, for<'all> Lend<'all, Self>: Clone,

Intersperse each lend of this lender with the given seperator.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1, 2].iter());
let mut interspersed = lender.intersperse(&0);
assert_eq!(interspersed.next(), Some(&1));
assert_eq!(interspersed.next(), Some(&0));
assert_eq!(interspersed.next(), Some(&2));
assert_eq!(interspersed.next(), None);
Source

fn intersperse_with<'call, G>( self, separator: G, ) -> IntersperseWith<'call, Self, G>
where Self: Sized, G: FnMut() -> Lend<'call, Self>,

Intersperse each lend of this lender with the seperator produced by the given function.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1, 2].iter());
let mut interspersed = lender.intersperse_with(|| &0);
assert_eq!(interspersed.next(), Some(&1));
assert_eq!(interspersed.next(), Some(&0));
assert_eq!(interspersed.next(), Some(&2));
assert_eq!(interspersed.next(), None);
Source

fn map<F>(self, f: F) -> Map<Self, F>
where Self: Sized, F: for<'all> FnMutHKA<'all, Lend<'all, Self>>,

Map each lend of this lender using the given function.

Please note that it is likely required that you use the hrc_mut! macro to create the closure.

§Examples
let mut data = [1, 2u8];
let mut lender = lender::lend_iter::<lend!(&'lend mut u8), _>(data.iter_mut());
let mut mapped = lender.map(hrc_mut!(for<'all> |a: &'all mut u8| -> &'all u8 {
    *a += 1;
    &*a
}));
assert_eq!(mapped.next(), Some(&2));
assert_eq!(mapped.next(), Some(&3));
assert_eq!(mapped.next(), None);
Source

fn map_into_iter<O, F: FnMut(Lend<'_, Self>) -> O>( self, f: F, ) -> MapIntoIter<Self, O, F>
where Self: Sized,

Map each lend of this lender into an owned value using the given function.

This is a weaker version of Lender::map that returns an Iterator instead of a Lender. However, this behavior is very common, and so this method is included for convenience. The main advantage is better type inference for the mapping function.

§Examples
let mut data = [1, 2u8];
let mut lender = lender::lend_iter::<lend!(&'lend mut u8), _>(data.iter_mut());
let mut mapped_into_iter = lender.map_into_iter(|a| {
    *a += 1;
    *a
});
assert_eq!(mapped_into_iter.next(), Some(2));
assert_eq!(mapped_into_iter.next(), Some(3));
assert_eq!(mapped_into_iter.next(), None);
Source

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

Call the given function with each lend of this lender.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1, 2u8].iter());
lender.for_each(|a| {
    let _ = *a + 1;
});
Source

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

Filter this lender using the given predicate.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1, 2u8].iter());
let mut filtered = lender.filter(|&a| *a > 1);
assert_eq!(filtered.next(), Some(&2));
assert_eq!(filtered.next(), None);
Source

fn filter_map<F>(self, f: F) -> FilterMap<Self, F>
where Self: Sized, F: for<'all> FnMutHKAOpt<'all, Lend<'all, Self>>,

Filter and map this lender using the given function.

§Examples
let mut data = [1, 2u8];
let mut lender = lender::lend_iter::<lend!(&'lend mut u8), _>(data.iter_mut());
let mut filtered = lender.filter_map(hrc_mut!(for<'all> |a: &'all mut u8| -> Option<&'all u8> {
    if *a > 1 {
        Some(&*a)
    } else {
        None
    }
}));
assert_eq!(filtered.next(), Some(&2));
assert_eq!(filtered.next(), None);
Source

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

Enumerate this lender. Each lend is paired with its zero-based index.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1, 2u8].iter());
let mut enumerated = lender.enumerate();
assert_eq!(enumerated.next(), Some((0, &1)));
assert_eq!(enumerated.next(), Some((1, &2)));
assert_eq!(enumerated.next(), None);
Source

fn peekable<'call>(self) -> Peekable<'call, Self>
where Self: Sized,

Make this lender peekable, so that it is possible to peek at the next lend without consuming it.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1, 2u8].iter());
let mut peekable = lender.peekable();
assert_eq!(peekable.peek(), Some(&&1));
assert_eq!(peekable.next(), Some(&1));
assert_eq!(peekable.peek(), Some(&&2));
assert_eq!(peekable.next(), Some(&2));
assert_eq!(peekable.peek(), None);
Source

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

Skip the first contiguous sequence lends of this lender that satisfy the given predicate.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1, 2, 3, 4, 5].iter());
let mut skipped = lender.skip_while(|&a| *a < 3);
assert_eq!(skipped.next(), Some(&3));
assert_eq!(skipped.next(), Some(&4));
assert_eq!(skipped.next(), Some(&5));
assert_eq!(skipped.next(), None);
Source

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

Take the first contiguous sequence lends of this lender that satisfy the given predicate.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1, 2, 3, 4, 5].iter());
let mut taken = lender.take_while(|&a| *a < 3);
assert_eq!(taken.next(), Some(&1));
assert_eq!(taken.next(), Some(&2));
assert_eq!(taken.next(), None);
Source

fn map_while<P>(self, predicate: P) -> MapWhile<Self, P>
where Self: Sized, P: for<'all> FnMutHKAOpt<'all, Lend<'all, Self>>,

Map this lender using the given function while it returns Some.

§Examples
let mut data = [1, 2u8];
let mut lender = lender::lend_iter::<lend!(&'lend mut u8), _>(data.iter_mut());
let mut mapped = lender.map_while(hrc_mut!(for<'all> |a: &'all mut u8| -> Option<&'all u8> {
    if *a < 2 {
        Some(&*a)
    } else {
        None
    }
}));
assert_eq!(mapped.next(), Some(&1));
assert_eq!(mapped.next(), None);
Source

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

Skip the first n lends of this lender.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1, 2, 3, 4, 5].iter());
let mut skipped = lender.skip(3);
assert_eq!(skipped.next(), Some(&4));
assert_eq!(skipped.next(), Some(&5));
assert_eq!(skipped.next(), None);
Source

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

Take the first n lends of this lender.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1, 2, 3, 4, 5].iter());
let mut taken = lender.take(2);
assert_eq!(taken.next(), Some(&1));
assert_eq!(taken.next(), Some(&2));
assert_eq!(taken.next(), None);
Source

fn scan<St, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
where Self: Sized, F: for<'all> FnMutHKAOpt<'all, (&'all mut St, Lend<'all, Self>)>,

Documentation is incomplete. Refer to Iterator::scan for more information.

Source

fn flat_map<'call, F>(self, f: F) -> FlatMap<'call, Self, F>
where Self: Sized, F: for<'all> FnMutHKA<'all, Lend<'all, Self>>, for<'all> <F as FnMutHKA<'all, Lend<'all, Self>>>::B: IntoLender,

Documentation is incomplete. Refer to Iterator::flat_map for more information

Source

fn flatten<'call>(self) -> Flatten<'call, Self>
where Self: Sized, for<'all> Lend<'all, Self>: IntoLender,

Documentation is incomplete. Refer to Iterator::flatten for more information

Source

fn fuse(self) -> Fuse<Self>
where Self: Sized,

Documentation is incomplete. Refer to Iterator::fuse for more information

Source

fn inspect<F>(self, f: F) -> Inspect<Self, F>
where Self: Sized, F: FnMut(&Lend<'_, Self>),

Documentation is incomplete. Refer to Iterator::inspect for more information

Source

fn mutate<F>(self, f: F) -> Mutate<Self, F>
where Self: Sized, F: FnMut(&mut Lend<'_, Self>),

Mutate each lend with the given function.

Source

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

Documentation is incomplete. Refer to Iterator::by_ref for more information

Source

fn collect<B>(self) -> B
where Self: Sized, B: FromLender<Self>,

Documentation is incomplete. Refer to Iterator::collect for more information

Source

fn try_collect<'a, B>(&'a mut self) -> ChangeOutputType<Lend<'a, Self>, B>
where Self: Sized, for<'all> Lend<'all, Self>: Try, for<'all> <Lend<'all, Self> as Try>::Residual: Residual<B>, for<'all> B: FromLender<TryShunt<'all, &'a mut Self>>,

Documentation is incomplete. Refer to Iterator::try_collect for more information

Source

fn collect_into<E>(self, collection: &mut E) -> &mut E
where Self: Sized, E: ExtendLender<Self>,

Documentation is incomplete. Refer to Iterator::collect_into for more information

Source

fn partition<A, E, F>(self, f: F) -> (E, E)
where Self: Sized, E: Default + ExtendLender<Self>, F: FnMut(&Lend<'_, Self>) -> bool,

Documentation is incomplete. Refer to Iterator::partition for more information

Source

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

Documentation is incomplete. Refer to Iterator::is_partitioned for more information

Source

fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R
where Self: Sized, F: FnMut(B, Lend<'_, Self>) -> R, R: Try<Output = B>,

Documentation is incomplete. Refer to Iterator::try_fold for more information

Source

fn try_for_each<F, R>(&mut self, f: F) -> R
where Self: Sized, F: FnMut(Lend<'_, Self>) -> R, R: Try<Output = ()>,

Documentation is incomplete. Refer to Iterator::try_for_each for more information

Source

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

Documentation is incomplete. Refer to Iterator::fold for more information

Source

fn reduce<T, F>(self, f: F) -> Option<T>
where Self: Sized, for<'all> Lend<'all, Self>: ToOwned<Owned = T>, F: FnMut(T, Lend<'_, Self>) -> T,

Documentation is incomplete. Refer to Iterator::reduce for more information

Source

fn try_reduce<T, F, R>(self, f: F) -> ChangeOutputType<R, Option<T>>
where Self: Sized, for<'all> Lend<'all, Self>: ToOwned<Owned = T>, F: FnMut(T, Lend<'_, Self>) -> R, R: Try<Output = T>, R::Residual: Residual<Option<T>>,

Documentation is incomplete. Refer to Iterator::try_reduce for more information

Source

fn all<F>(&mut self, f: F) -> bool
where Self: Sized, F: FnMut(Lend<'_, Self>) -> bool,

Documentation is incomplete. Refer to Iterator::all for more information

Source

fn any<F>(&mut self, f: F) -> bool
where Self: Sized, F: FnMut(Lend<'_, Self>) -> bool,

Documentation is incomplete. Refer to Iterator::any for more information

Source

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

Documentation is incomplete. Refer to Iterator::find for more information

Source

fn find_map<'a, F>( &'a mut self, f: F, ) -> Option<<F as FnMutHKAOpt<'a, Lend<'a, Self>>>::B>
where Self: Sized, F: for<'all> FnMutHKAOpt<'all, Lend<'all, Self>>,

Documentation is incomplete. Refer to Iterator::find_map for more information

Source

fn try_find<F, R>( &mut self, f: F, ) -> ChangeOutputType<R, Option<Lend<'_, Self>>>
where Self: Sized, F: FnMut(&Lend<'_, Self>) -> R, R: Try<Output = bool>, for<'all> R::Residual: Residual<Option<Lend<'all, Self>>>,

Documentation is incomplete. Refer to Iterator::try_find for more information

Source

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

Documentation is incomplete. Refer to Iterator::position for more information

Source

fn rposition<P>(&mut self, predicate: P) -> Option<usize>
where P: FnMut(Lend<'_, Self>) -> bool, Self: Sized + ExactSizeLender + DoubleEndedLender,

Documentation is incomplete. Refer to Iterator::rposition for more information

Source

fn max<T>(self) -> Option<T>
where Self: Sized, T: for<'all> PartialOrd<Lend<'all, Self>>, for<'all> Lend<'all, Self>: ToOwned<Owned = T>,

Documentation is incomplete. Refer to Iterator::max for more information

Source

fn min<T>(self) -> Option<T>
where Self: Sized, T: for<'all> PartialOrd<Lend<'all, Self>>, for<'all> Lend<'all, Self>: ToOwned<Owned = T>,

Documentation is incomplete. Refer to Iterator::min for more information

Source

fn max_by_key<B: Ord, T, F>(self, f: F) -> Option<T>
where Self: Sized, for<'all> Lend<'all, Self>: ToOwned<Owned = T>, F: FnMut(&T) -> B,

Documentation is incomplete. Refer to Iterator::max_by_key for more information

Source

fn max_by<T, F>(self, compare: F) -> Option<T>
where Self: Sized, for<'all> Lend<'all, Self>: ToOwned<Owned = T>, F: FnMut(&T, &Lend<'_, Self>) -> Ordering,

Documentation is incomplete. Refer to Iterator::max_by for more information

Source

fn min_by_key<B: Ord, T, F>(self, f: F) -> Option<T>
where Self: Sized, for<'all> Lend<'all, Self>: ToOwned<Owned = T>, F: FnMut(&T) -> B,

Documentation is incomplete. Refer to Iterator::min_by_key for more information

Source

fn min_by<T, F>(self, compare: F) -> Option<T>
where Self: Sized, for<'all> Lend<'all, Self>: ToOwned<Owned = T>, F: FnMut(&T, &Lend<'_, Self>) -> Ordering,

Documentation is incomplete. Refer to Iterator::min_by for more information

Source

fn rev(self) -> Rev<Self>
where Self: Sized + DoubleEndedLender,

Documentation is incomplete. Refer to Iterator::rev for more information

Source

fn unzip<ExtA, ExtB>(self) -> (ExtA, ExtB)
where Self: Sized, for<'all> Lend<'all, Self>: TupleLend<'all>, ExtA: Default + ExtendLender<FirstShunt<Self>>, ExtB: Default + ExtendLender<SecondShunt<Self>>,

Documentation is incomplete. Refer to Iterator::unzip for more information

Source

fn copied<T>(self) -> Copied<Self>
where Self: Sized + for<'all> Lending<'all, Lend = &'all T>, T: Copy,

Documentation is incomplete. Refer to Iterator::copied for more information.

Turns this Lender into an Iterator.

Source

fn cloned<T>(self) -> Cloned<Self>
where Self: Sized + for<'all> Lending<'all, Lend = &'all T>, T: Clone,

Documentation is incomplete. Refer to Iterator::cloned for more information.

Turns this Lender into an Iterator.

Source

fn owned(self) -> Owned<Self>
where Self: Sized, for<'all> Lend<'all, Self>: ToOwned,

Turn this Lender into an Iterator.

Source

fn cycle(self) -> Cycle<Self>
where Self: Sized + Clone,

Documentation is incomplete. Refer to Iterator::cycle for more information

Source

fn sum<S>(self) -> S
where Self: Sized, S: SumLender<Self>,

Documentation is incomplete. Refer to Iterator::sum for more information

Source

fn product<P>(self) -> P
where Self: Sized, P: ProductLender<Self>,

Documentation is incomplete. Refer to Iterator::product for more information

Source

fn cmp<L>(self, other: L) -> Ordering
where L: IntoLender, L::Lender: for<'all> Lending<'all, Lend = Lend<'all, Self>>, for<'all> Lend<'all, Self>: Ord, Self: Sized,

Documentation is incomplete. Refer to Iterator::cmp for more information

Source

fn cmp_by<L, F>(self, other: L, cmp: F) -> Ordering
where Self: Sized, L: IntoLender, F: for<'all> FnMut(Lend<'all, Self>, Lend<'all, L::Lender>) -> Ordering,

Documentation is incomplete. Refer to Iterator::cmp_by for more information

Source

fn partial_cmp<L>(self, other: L) -> Option<Ordering>
where L: IntoLender, for<'all> Lend<'all, Self>: PartialOrd<Lend<'all, L::Lender>>, Self: Sized,

Documentation is incomplete. Refer to Iterator::partial_cmp for more information

Source

fn partial_cmp_by<L, F>(self, other: L, partial_cmp: F) -> Option<Ordering>
where Self: Sized, L: IntoLender, F: for<'all> FnMut(Lend<'all, Self>, Lend<'all, L::Lender>) -> Option<Ordering>,

Documentation is incomplete. Refer to Iterator::partial_cmp_by for more information

Source

fn eq<L>(self, other: L) -> bool
where L: IntoLender, for<'all> Lend<'all, Self>: PartialEq<Lend<'all, L::Lender>>, Self: Sized,

Documentation is incomplete. Refer to Iterator::eq for more information

Source

fn eq_by<L, F>(self, other: L, eq: F) -> bool
where Self: Sized, L: IntoLender, F: for<'all> FnMut(Lend<'all, Self>, Lend<'all, L::Lender>) -> bool,

Documentation is incomplete. Refer to Iterator::eq_by for more information

Source

fn ne<L>(self, other: L) -> bool
where L: IntoLender, for<'all> Lend<'all, Self>: PartialEq<Lend<'all, L::Lender>>, Self: Sized,

Documentation is incomplete. Refer to Iterator::ne for more information

Source

fn lt<L>(self, other: L) -> bool
where L: IntoLender, for<'all> Lend<'all, Self>: PartialOrd<Lend<'all, L::Lender>>, Self: Sized,

Documentation is incomplete. Refer to Iterator::lt for more information

Source

fn le<L>(self, other: L) -> bool
where L: IntoLender, for<'all> Lend<'all, Self>: PartialOrd<Lend<'all, L::Lender>>, Self: Sized,

Documentation is incomplete. Refer to Iterator::le for more information

Source

fn gt<L>(self, other: L) -> bool
where L: IntoLender, for<'all> Lend<'all, Self>: PartialOrd<Lend<'all, L::Lender>>, Self: Sized,

Documentation is incomplete. Refer to Iterator::gt for more information

Source

fn ge<L>(self, other: L) -> bool
where L: IntoLender, for<'all> Lend<'all, Self>: PartialOrd<Lend<'all, L::Lender>>, Self: Sized,

Documentation is incomplete. Refer to Iterator::ge for more information

Source

fn is_sorted<T>(self) -> bool
where Self: Sized, for<'all> Lend<'all, Self>: ToOwned<Owned = T>, T: PartialOrd,

Documentation is incomplete. Refer to Iterator::is_sorted for more information

Source

fn is_sorted_by<T, F>(self, compare: F) -> bool
where Self: Sized, for<'all> Lend<'all, Self>: ToOwned<Owned = T>, F: FnMut(&T, &T) -> Option<Ordering>,

Documentation is incomplete. Refer to Iterator::is_sorted_by for more information

Source

fn is_sorted_by_key<F, K>(self, f: F) -> bool
where Self: Sized, F: FnMut(Lend<'_, Self>) -> K, K: PartialOrd,

Documentation is incomplete. Refer to Iterator::is_sorted_by_key for more information

Source

fn iter<'this>(self) -> Iter<'this, Self>
where Self: Sized + 'this, for<'all> Lend<'all, Self>: 'this,

Turn this lender into an Iterator where it has already fulfilled the requirements of the Iterator trait.

Source

fn chunky(self, chunk_size: usize) -> Chunky<Self>
where Self: Sized + ExactSizeLender,

A lending replacement for Iterator::array_chunks.

It is not possible to implement the exact behavior of Iterator::array_chunks in a lender, so this is the closest approximation: at each iteration, it yields a lender returning the next chunk_size lends.

§Examples
let mut lender = lender::lend_iter::<lend!(&'lend u8), _>([1u8, 2, 3].iter());
let mut chunky = lender.chunky(2);
let mut chunk1 = chunky.next().unwrap();
assert_eq!(chunk1.next(), Some(&1));
assert_eq!(chunk1.next(), Some(&2));
assert_eq!(chunk1.next(), None);
let mut chunk2 = chunky.next().unwrap();
assert_eq!(chunk2.next(), Some(&3));
assert_eq!(chunk2.next(), None);
Source

fn into_fallible<E>(self) -> IntoFallible<E, Self>
where Self: Sized,

Convert an lender of anything into FallibleLender by wrapping into Result<Lend<'_, Self>, E> where E is an error that can never actually happen.

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<L: Lender> Lender for &mut L

Source§

fn next(&mut self) -> Option<Lend<'_, Self>>

Source§

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

Source§

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

Implementors§

Source§

impl<'a, L> Lender for Once<'a, L>
where L: ?Sized + for<'all> Lending<'all>,

Source§

impl<'a, L> Lender for Repeat<'a, L>
where L: ?Sized + for<'all> Lending<'all> + 'a, for<'all> Lend<'all, L>: Clone,

Source§

impl<'a, L, F> Lender for RepeatWith<'a, L, F>
where L: ?Sized + for<'all> Lending<'all> + 'a, F: FnMut() -> Lend<'a, L>,

Source§

impl<'a, L, I> Lender for LendIter<'a, L, I>
where L: ?Sized + for<'all> Lending<'all> + 'a, I: Iterator<Item = Lend<'a, L>>,

Source§

impl<'this, L> Lender for Intersperse<'this, L>
where for<'all> Lend<'all, L>: Clone, L: Lender,

Source§

impl<'this, L> Lender for Peekable<'this, L>
where L: Lender,

Source§

impl<'this, L, G> Lender for IntersperseWith<'this, L, G>
where L: Lender, G: FnMut() -> Lend<'this, L>,

Source§

impl<'this, L: Lender> Lender for TryShunt<'this, L>
where for<'all> Lend<'all, L>: Try,

Source§

impl<A, B> Lender for Chain<A, B>
where A: Lender, B: Lender + for<'all> Lending<'all, Lend = Lend<'all, A>>,

Source§

impl<A, B> Lender for Zip<A, B>
where A: Lender, B: Lender,

Source§

impl<I: Iterator> Lender for FromIter<I>

Source§

impl<L> Lender for Chunky<L>
where L: Lender,

Source§

impl<L> Lender for Cycle<L>
where L: Clone + Lender,

Source§

impl<L> Lender for Empty<L>
where L: ?Sized + for<'all> Lending<'all>,

Source§

impl<L> Lender for Enumerate<L>
where L: Lender,

Source§

impl<L> Lender for Fuse<L>
where L: Lender,

Source§

impl<L> Lender for Rev<L>

Source§

impl<L> Lender for Skip<L>
where L: Lender,

Source§

impl<L> Lender for StepBy<L>
where L: Lender,

Source§

impl<L> Lender for Take<L>
where L: Lender,

Source§

impl<L, F> Lender for FilterMap<L, F>
where for<'all> F: FnMutHKAOpt<'all, Lend<'all, L>>, L: Lender,

Source§

impl<L, F> Lender for Inspect<L, F>
where L: Lender, F: FnMut(&Lend<'_, L>),

Source§

impl<L, F> Lender for Map<L, F>
where F: for<'all> FnMutHKA<'all, Lend<'all, L>>, L: Lender,

Source§

impl<L, F> Lender for Mutate<L, F>
where L: Lender, F: FnMut(&mut Lend<'_, L>),

Source§

impl<L, P> Lender for Filter<L, P>
where P: FnMut(&Lend<'_, L>) -> bool, L: Lender,

Source§

impl<L, P> Lender for MapWhile<L, P>
where P: for<'all> FnMutHKAOpt<'all, Lend<'all, L>>, L: Lender,

Source§

impl<L, P> Lender for SkipWhile<L, P>
where P: FnMut(&Lend<'_, L>) -> bool, L: Lender,

Source§

impl<L, P> Lender for TakeWhile<L, P>
where P: FnMut(&Lend<'_, L>) -> bool, L: Lender,

Source§

impl<L, St, F> Lender for Scan<L, St, F>
where for<'all> F: FnMutHKAOpt<'all, (&'all mut St, Lend<'all, L>)>, L: Lender,

Source§

impl<L: Lender> Lender for Flatten<'_, L>
where for<'all> Lend<'all, L>: IntoLender,

Source§

impl<L: Lender, F> Lender for FlatMap<'_, L, F>
where Map<L, F>: Lender, for<'all> Lend<'all, Map<L, F>>: IntoLender,

Source§

impl<St, F> Lender for FromFn<St, F>
where F: for<'all> FnMutHKAOpt<'all, &'all mut St>,

Source§

impl<St, F> Lender for OnceWith<St, F>
where F: for<'all> FnOnceHKA<'all, &'all mut St>,

Source§

impl<T> Lender for Chunk<'_, T>
where T: Lender,

Source§

impl<T> Lender for WindowsMut<'_, T>

Source§

impl<T, const WINDOW_SIZE: usize> Lender for ArrayWindowsMut<'_, T, WINDOW_SIZE>