"Generic Associated Types" Charter

Goals

Extend traits by permitting associated types to have generic parameters (types, lifetimes).

This enables writing traits that capture more complex patterns:

  • an [Iterable] trait for collections that support an iter method, yielding references into themselves
  • a [Mode] trait

It also provides the technical foundation of async functions in traits and return-position impl Trait in traits (although this dependence is internal to the compiler and exposed to users).

  • Concretely, extend associated types with generic parameters.
  • This makes it possible to write traits describing more complex patterns, e.g.
    • methods with arguments or return values that borrow from other arguments
  • Extend Rust traits to describe patterns that currently cannot be described...
    • associated types that reference
  • Extend associated types on traits to have type and lifetime parameters.

Membership