Trait Lending

Source
pub trait Lending<'lend, __ImplBound = Ref<'lend, Self>>
where __ImplBound: ImplBound,
{ type Lend: 'lend; }
Expand description

A trait for dealing with the ‘items’ of lending iterators.

Must be defined for any type that implements Lender.

It implicitly restricts the lifetime 'lend used in Lending<'lend> to be where Self: 'lend.

This is a result of Higher-Ranked Trait Bounds (HRTBs) not having a way to express qualifiers (for<'any where Self: 'any> Self: Trait) and effectively making HRTBs only useful when you want to express a trait constraint on ALL lifetimes, including ’static (for<'all> Self: trait)

Although the common example of implementing your own LendingIterator uses a (type Item<'a> where Self: 'a;) GAT, that generally only works withing a small subset of the features that a LendingIterator needs to provide to be comparable to Iterator.

Please see Sabrina Jewson’s Blog for more information, and how a trait like this can be used to solve it by implicitly restricting HRTBs.

Required Associated Types§

Source

type Lend: 'lend

The type being lent.

Implementations on Foreign Types§

Source§

impl<'lend, L> Lending<'lend> for &mut L
where L: Lender,

Source§

type Lend = <L as Lending<'lend>>::Lend

Implementors§

Source§

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

Source§

type Lend = <L as Lending<'lend>>::Lend

Source§

impl<'any, T> Lending<'any> for WindowsMut<'_, T>

Source§

type Lend = &'any mut [T]

Source§

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

Source§

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

Source§

type Lend = <L as Lending<'lend>>::Lend

Source§

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

Source§

type Lend = <L as Lending<'lend>>::Lend

Source§

impl<'lend, 'this, L> Lending<'lend> for Flatten<'this, L>
where L: Lender, <L as Lending<'all>>::Lend: for<'all> IntoLender,

Source§

type Lend = <<<L as Lending<'this>>::Lend as IntoLender>::Lender as Lending<'lend>>::Lend

Source§

impl<'lend, 'this, L, F> Lending<'lend> for FlatMap<'this, L, F>
where L: Lender, Map<L, F>: Lender, <Map<L, F> as Lending<'all>>::Lend: for<'all> IntoLender,

Source§

type Lend = <<<Map<L, F> as Lending<'this>>::Lend as IntoLender>::Lender as Lending<'lend>>::Lend

Source§

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

Source§

type Lend = <L as Lending<'lend>>::Lend

Source§

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

Source§

type Lend = <A as Lending<'lend>>::Lend

Source§

impl<'lend, A, B> Lending<'lend> for Zip<A, B>
where A: Lender, B: Lender,

Source§

type Lend = (<A as Lending<'lend>>::Lend, <B as Lending<'lend>>::Lend)

Source§

impl<'lend, B, L, F> Lending<'lend> for FilterMap<L, F>
where F: FnMut(<L as Lending<'lend>>::Lend) -> Option<B>, B: 'lend, L: Lender,

Source§

type Lend = B

Source§

impl<'lend, B, L, P> Lending<'lend> for MapWhile<L, P>
where P: FnMut(<L as Lending<'lend>>::Lend) -> Option<B>, L: Lender, B: 'lend,

Source§

type Lend = B

Source§

impl<'lend, B, L, St, F> Lending<'lend> for Scan<L, St, F>
where F: FnMut((&'lend mut St, <L as Lending<'lend>>::Lend)) -> Option<B>, L: Lender, B: 'lend,

Source§

type Lend = B

Source§

impl<'lend, L> Lending<'lend> for Chunky<L>
where L: Lender,

Source§

type Lend = Chunk<'lend, L>

Source§

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

Source§

type Lend = <L as Lending<'lend>>::Lend

Source§

impl<'lend, L> Lending<'lend> for Enumerate<L>
where L: Lender,

Source§

type Lend = (usize, <L as Lending<'lend>>::Lend)

Source§

impl<'lend, L> Lending<'lend> for Fuse<L>
where L: Lender,

Source§

type Lend = <L as Lending<'lend>>::Lend

Source§

impl<'lend, L> Lending<'lend> for Intersperse<'_, L>
where <L as Lending<'all>>::Lend: for<'all> Clone, L: Lender,

Source§

type Lend = <L as Lending<'lend>>::Lend

Source§

impl<'lend, L> Lending<'lend> for Peekable<'_, L>
where L: Lender,

Source§

type Lend = <L as Lending<'lend>>::Lend

Source§

impl<'lend, L> Lending<'lend> for Rev<L>
where L: Lender,

Source§

type Lend = <L as Lending<'lend>>::Lend

Source§

impl<'lend, L> Lending<'lend> for Skip<L>
where L: Lender,

Source§

type Lend = <L as Lending<'lend>>::Lend

Source§

impl<'lend, L> Lending<'lend> for StepBy<L>
where L: Lender,

Source§

type Lend = <L as Lending<'lend>>::Lend

Source§

impl<'lend, L> Lending<'lend> for FirstShunt<L>
where L: Lender, <L as Lending<'all>>::Lend: for<'all> TupleLend<'all>,

Source§

type Lend = <<L as Lending<'lend>>::Lend as TupleLend<'lend>>::First

Source§

impl<'lend, L> Lending<'lend> for SecondShunt<L>
where L: Lender, <L as Lending<'all>>::Lend: for<'all> TupleLend<'all>,

Source§

type Lend = <<L as Lending<'lend>>::Lend as TupleLend<'lend>>::Second

Source§

impl<'lend, L> Lending<'lend> for TryShunt<'_, L>
where L: Lender, <L as Lending<'all>>::Lend: for<'all> Try,

Source§

type Lend = <<L as Lending<'lend>>::Lend as Try>::Output

Source§

impl<'lend, L> Lending<'lend> for Take<L>
where L: Lender,

Source§

type Lend = <L as Lending<'lend>>::Lend

Source§

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

Source§

type Lend = <L as Lending<'lend>>::Lend

Source§

impl<'lend, L> Lending<'lend> for Once<'_, L>
where L: for<'all> Lending<'all> + ?Sized,

Source§

type Lend = <L as Lending<'lend>>::Lend

Source§

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

Source§

type Lend = <L as Lending<'lend>>::Lend

Source§

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

Source§

type Lend = <F as FnMutHKA<'lend, <L as Lending<'lend>>::Lend>>::B

Source§

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

Source§

type Lend = <L as Lending<'lend>>::Lend

Source§

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

Source§

type Lend = <L as Lending<'lend>>::Lend

Source§

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

Source§

type Lend = <L as Lending<'lend>>::Lend

Source§

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

Source§

type Lend = <L as Lending<'lend>>::Lend

Source§

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

Source§

type Lend = <F as FnMutHKAOpt<'lend, &'lend mut St>>::B

Source§

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

Source§

type Lend = <F as FnOnceHKA<'lend, &'lend mut St>>::B

Source§

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

Source§

type Lend = <T as Lending<'lend>>::Lend

Source§

impl<I> Lending<'_> for FromIter<I>
where I: Iterator,

Source§

type Lend = <I as Iterator>::Item