Reputation: 24577
Is there a reason tuples, structs, and tuple structs need to have inconsistent syntax in Rust?
I'm still reading the manual, so there may be an obvious answer to this, but couldn't the syntax be unified so that all of the following are legal?:
struct { Int, Int }
struct Foo { Int, Int }
struct { a: Int, b: Int }
struct Foo { a: int, b: Int }
struct Foo { Int, a: Int, b: Int, Int }
If there is some technical reason to avoid mixing named and unnamed parameters, you could keep the unnamed parameters in the ()
and named parameters in the {}
...
struct (Int, Int);
struct Foo(Int, Int);
struct { a: Int, b: Int }
struct Foo { a: Int, b: Int }
struct Foo(Int, Int) { a: Int, b: Int }
Upvotes: 3
Views: 1362
Reputation: 100170
No, but none of the alternative proposals seemed worth breaking all existing code.
https://internals.rust-lang.org/t/unify-structs-tuples-and-funciton-calls/1667
Upvotes: 2