Something that would be very useful in Rust would be having associated types that can take lifetime parameters, which allows to implement things like the “streaming iterator” trait and in general support traits that can provide generic temporary values.
This could in theory be done right now by having an associated type with an HRTB lifetime bound for a trait with an associated type, like this:
trait R2T<'a>
{
type T;
}
trait StreamingIterator
{
type Item: for<'x> R2T<'x>;
fn next<'a>(&'a self) -> <Self::Item as R2T<'a>>::T;
}
Except that the compiler is broken so in many cases this kind of pattern doesn’t compile.
Starting from two years ago, numerous bugs about this have been filed and are still open (e.g. https://github.com/rust-lang/rust/issues/30472, https://github.com/rust-lang/rust/issues/31580, https://github.com/rust-lang/rust/issues/30867).
Any chance this could be fixed, since it’s quite an essential abstraction to have?
Also, having support for “for<'a: 'b>” syntax would be great as well, and then also “for<T>” (with bounds on T) and generic associated type constructors, and also specialization so the type mappings can be arbitrary.