I think the feature you're looking for is generic associated types. Rust has this: 1598-generic_associated_types - The Rust RFC Book
Swift allowing this some day is not outside the realm of possibility, but it's not completely trivial (the Rust folks spent several years designing and implementing this, AFAIK).
It would require an overhaul of how the requirement machine builds a rewrite system from requirements, which currently makes a pretty fundamental assumption that associated types are unary type constructors (T.Element is kind of like Element<T>
; a generic associated type T.MapResult<E>
has two arguments, T
and E
).
We would also need to think about how the runtime type metadata side of this works, too.
One day I will finish (start) documenting how the requirement machine works, and maybe then more folks can get involved in discussing future directions for generics.