> ```
> forall<T, U> struct Foo { ... }
> forall<T, U> impl Trait<T> for Foo<T, U> { ... }
> forall<T, U> fn foo(...) { ... }
> ```


I’m new to rust, so maybe this doesn’t make sense, but would it make sense to 
have a variation of this syntax to make implementing related traits and 
functions more DRY?  Essentially allow the for all to be shared.  While I’ve 
been skimming code to learn Rust, I noticed trait restrictions in particular 
seem to be repeated a lot in functions and traits that are related to each 
other.

forall<T:ByteStream, U> {
        impl BinaryEncoder<T> for MyStruct<U> { … }
        impl BinaryDecoder<T> for MyStruct<U> { … }
}

I also like how it breaks across lines:

forall<T, U>
struct Foo {
...
}

It looks like someone else suggested this while I was typing, but I like the 
aesthetics of it.

-Eric
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to