4 ms·
Still no GAT
by hsfzxjy 4y ago
Still no GAT
- mbStavola 4y agoNext release, I believe, along with let-else.
- pjerem 4y agoWhat is that ?
- noisem4ker 4y agoGeneric Associated Types https://rust-lang.github.io/generic-associated-types-initiative/mvp.html https://rust-lang.github.io/generic-associated-types-initiat...
- steveklabnik 4y agoMy sibling has the super details, but at a high level: 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.