That is not the right definition. You removed the lifetime annotation. Here's the trait:
pub trait Streamer<'a> {
type Item: 'a;
fn next(&'a mut self) -> Option<Self::Item>;
}
In some world where HKT exists, the trait definition might look like:
pub trait Streamer {
type Item;
fn next<'a>(&'a mut self) -> Option<Self::Item<'a>>;
}
But this is polymorphic code on type constructors, where Self::Item
is a type constructor.
You asked for examples where HKT was needed. I gave you a link to a use case. Your code does not apply to my use case.
I want an abstraction that lets me write iterators whose elements can be borrowed from the iterator.