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-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.