Still no GAT
https://rust-lang.github.io/generic-associated-types-initiat...
Rust lets you have generic types on structs and functions:
// T is a generic type parameter, x has type T
fn foo<T>(x: T) -> {
Rust also lets you have "associated types": trait MyIterator {
type Item;
fn next(&mut self) -> Option<Self::Item>;
}
struct Alternate {
state: i32,
}
impl MyIterator for Alternate {
// because we choose the Item type here...
type Item = i32;
// that determines the type that gets returned down here
fn next(&mut self) -> Option<Self::Item> {
In today's Rust, `type Item` cannot be a generic type: // lifetimes are generics, so if you try this...
trait MyIterator {
type Item<'a>;
// you'll get this error message
error[E0658]: generic associated types are unstable
In the near future, combining these two features will be allowed.