pub trait LendingIteratorDyn {
    type Item: ?Sized + HKT;

    fn dyn_next(&mut self) -> Option<Feed<'_, Self::Item>>;
}
Expand description

dyn-friendly (dyn-safe) version of LendingIterator.

It is automagically implemented for all types implementing LendingIterator, and, conversely, LendingIterator is implemented for dyn LendingIteratorDyn.

Limitations

Beware that such a trait does still not play well with contexts which are generic over the “lending mode” ⚠️

So, if you intend to unify two heterogeneous LendingIterator under the same dyn LendingIteratorDyn, make sure to hard-code the dependency on the 'next-lending lifetime.

Otherwise you might have to:

Example: dyn coercion of a fully generic LendingIterator:

  • use ::lending_iterator::prelude::*;
    
    fn coercions<'T, Item, T> (it: T)
    where
        Item : HKT,
        T : 'T + Send + Sync + LendingIterator,
        // THIS IS THE BOUND THAT YOU HAVE TO ADD TO MAKE IT WORK, for some reason:
        T : LendingIteratorDyn<Item = CanonicalHKT<Item>>, // 👈
    {
        match () {
            _ => {
                let _: Box<dyn 'T + LendingIteratorDyn<Item = CanonicalHKT<Item>>> =
                    it.dyn_boxed_auto()
                ;
            },
            _ => {
                let _: Box<dyn 'T + LendingIteratorDyn<Item = CanonicalHKT<Item>> + Send> =
                    it.dyn_boxed_auto()
                ;
            },
            _ => {
                let _: Box<dyn 'T + LendingIteratorDyn<Item = CanonicalHKT<Item>> + Sync> =
                    it.dyn_boxed_auto()
                ;
            },
            _ => {
                let _: Box<dyn 'T + LendingIteratorDyn<Item = CanonicalHKT<Item>> + Send + Sync> =
                    it.dyn_boxed_auto()
                ;
            },
        }
    }

Required Associated Types

Another approach to a GAT in stable Rust: use a classic associated type, but with a HKT bound on it, so that it can still be fed a lifetime parameter.

Required Methods

A dyn-safe version of LendingIterator::next(), using [Self::Item].

Given that LendingIteratorDyn : LendingIterator, you should not need to call this function directly: calling .next() ought to work just as well.

  • That being said, if defining a LendingIteratorDyn subtrait, you may then need to directly call into it.

Trait Implementations

dyn LendingIteratorDyn + … : LendingIterator

Query the next() Item of this Self iterator. Read more

Convenience method: same as .map(), but for hard-coding the HKT parameter to HKTRef<R> = HKT!(&R). Read more

Convenience method: same as .map(), but for hard-coding the HKT parameter to HKTRefMut<R> = HKT!(&mut R). Read more

Convenience shorthand for .map…(…).into_iter(). Read more

Convenience method: same as .filter_map(), but for hard-coding the HKT parameter to HKTRef<R> = HKT!(&R). Read more

Convenience method: same as .filter_map(), but for hard-coding the HKT parameter to HKTRefMut<R> = HKT!(&mut R). Read more

Convenience shorthand for .filter_map…(…).into_iter(). Read more

Convert a Self : LendingIterator into an Iterator, provided Self::Item<'_> does not depend on '_. Read more

Available on crate feature alloc only.

Converts this LendingIterator into a Box<dyn LendingIteratorDyn…>. Read more

Available on crate feature alloc only.

Converts this LendingIterator into a Box<dyn LendingIteratorDyn…>. Read more

dyn LendingIteratorDyn + … : LendingIterator

Query the next() Item of this Self iterator. Read more

Convenience method: same as .map(), but for hard-coding the HKT parameter to HKTRef<R> = HKT!(&R). Read more

Convenience method: same as .map(), but for hard-coding the HKT parameter to HKTRefMut<R> = HKT!(&mut R). Read more

Convenience shorthand for .map…(…).into_iter(). Read more

Convenience method: same as .filter_map(), but for hard-coding the HKT parameter to HKTRef<R> = HKT!(&R). Read more

Convenience method: same as .filter_map(), but for hard-coding the HKT parameter to HKTRefMut<R> = HKT!(&mut R). Read more

Convenience shorthand for .filter_map…(…).into_iter(). Read more

Convert a Self : LendingIterator into an Iterator, provided Self::Item<'_> does not depend on '_. Read more

Available on crate feature alloc only.

Converts this LendingIterator into a Box<dyn LendingIteratorDyn…>. Read more

Available on crate feature alloc only.

Converts this LendingIterator into a Box<dyn LendingIteratorDyn…>. Read more

dyn LendingIteratorDyn + … : LendingIterator

Query the next() Item of this Self iterator. Read more

Convenience method: same as .map(), but for hard-coding the HKT parameter to HKTRef<R> = HKT!(&R). Read more

Convenience method: same as .map(), but for hard-coding the HKT parameter to HKTRefMut<R> = HKT!(&mut R). Read more

Convenience shorthand for .map…(…).into_iter(). Read more

Convenience method: same as .filter_map(), but for hard-coding the HKT parameter to HKTRef<R> = HKT!(&R). Read more

Convenience method: same as .filter_map(), but for hard-coding the HKT parameter to HKTRefMut<R> = HKT!(&mut R). Read more

Convenience shorthand for .filter_map…(…).into_iter(). Read more

Convert a Self : LendingIterator into an Iterator, provided Self::Item<'_> does not depend on '_. Read more

Available on crate feature alloc only.

Converts this LendingIterator into a Box<dyn LendingIteratorDyn…>. Read more

Available on crate feature alloc only.

Converts this LendingIterator into a Box<dyn LendingIteratorDyn…>. Read more

dyn LendingIteratorDyn + … : LendingIterator

Query the next() Item of this Self iterator. Read more

Convenience method: same as .map(), but for hard-coding the HKT parameter to HKTRef<R> = HKT!(&R). Read more

Convenience method: same as .map(), but for hard-coding the HKT parameter to HKTRefMut<R> = HKT!(&mut R). Read more

Convenience shorthand for .map…(…).into_iter(). Read more

Convenience method: same as .filter_map(), but for hard-coding the HKT parameter to HKTRef<R> = HKT!(&R). Read more

Convenience method: same as .filter_map(), but for hard-coding the HKT parameter to HKTRefMut<R> = HKT!(&mut R). Read more

Convenience shorthand for .filter_map…(…).into_iter(). Read more

Convert a Self : LendingIterator into an Iterator, provided Self::Item<'_> does not depend on '_. Read more

Available on crate feature alloc only.

Converts this LendingIterator into a Box<dyn LendingIteratorDyn…>. Read more

Available on crate feature alloc only.

Converts this LendingIterator into a Box<dyn LendingIteratorDyn…>. Read more

The “output” of this whole hand-rolled GAT: think of LendingIteratorඞItem<'lt>::T as of LendingIterator::Item<'lt>. Read more

The “output” of this whole hand-rolled GAT: think of LendingIteratorඞItem<'lt>::T as of LendingIterator::Item<'lt>. Read more

The “output” of this whole hand-rolled GAT: think of LendingIteratorඞItem<'lt>::T as of LendingIterator::Item<'lt>. Read more

The “output” of this whole hand-rolled GAT: think of LendingIteratorඞItem<'lt>::T as of LendingIterator::Item<'lt>. Read more

Implementors

impl LendingIterator : LendingIteratorDyn