pub trait Lending<'lend, __ImplBound: ImplBound = Ref<'lend, Self>> {
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-Rank 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 lending iterator uses a
(type Item<'a> where Self: 'a;) GAT, that generally only works within a
small subset of the features that a lending iterator 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.