(no title)
xscott | 3 months ago
It's practically your job to defend Rust, so I don't expect you to budge even one inch. However, I hate the idea of letting you mislead the casual reader that this is somehow equivalent and "just how languages work".
The grammar could've used `Generic[Specific]` with square brackets and avoided the need for the turbo fish.
steveklabnik|3 months ago
If you're being overly literal, yes, the <>s are needed here for this exact syntax. My point was not about this specific example, it's that these forms are equivalent, but some of them are syntactically simpler than others. The existence of redundant forms does not make the syntax illegitimate, or overly complex.
For this specific issue, if square brackets were used for generics, then something else would have to change for array indexing, and folks would be complaining that Rust doesn't do what every other language does here, which is its own problem.
xscott|3 months ago
The compiler knows when the `A` in `A[B]` is a type vs a variable.
kstrauser|3 months ago
But then people would grouse about it using left-bracket and right-bracket as brackets in a type "context".
GoblinSlayer|3 months ago
xscott|3 months ago