seekable_iterator/lending_iterator_support.rs
1#[doc(hidden)]
2pub trait ImplyBound: sealed::Sealed {}
3
4mod sealed {
5 #[expect(unnameable_types, reason = "this is intentional, to create a sealed trait")]
6 pub trait Sealed {}
7}
8
9impl<T: ?Sized> ImplyBound for &T {}
10impl<T: ?Sized> sealed::Sealed for &T {}
11
12/// Trait for getting the item of a lending iterator.
13///
14/// The lifetime can force the consumer to drop the item before obtaining a new item (which
15/// requires a mutable borrow to the iterator, invalidating the borrow of the previous item).
16///
17/// See [`lender`] for why this strategy is used instead of a simple GAT.
18///
19#[cfg_attr(not(feature = "lender"), doc = " [`lender`]: <https://docs.rs/lender/0.4/lender>")]
20pub trait LendItem<'lend, __ImplyBound: ImplyBound = &'lend Self> {
21 /// The item of a lending iterator, with a particular lifetime.
22 ///
23 /// The lifetime can force the consumer to drop the item before obtaining a new item (which
24 /// requires a mutable borrow to the iterator, invalidating the borrow of the previous item).
25 type Item: 'lend;
26}
27
28/// The item of a lending iterator, with a particular lifetime.
29///
30/// The lifetime can force the consumer to drop the item before obtaining a new item (which
31/// requires a mutable borrow to the iterator, invalidating the borrow of the previous item).
32pub type LentItem<'lend, L> = <L as LendItem<'lend>>::Item;