Closed CharlyCst closed 3 years ago
What?
Struct literal require to specify the field for each value, even when it is redundant with the name of the variable:
struct Point { x: i32 y: i32 } Point { x: x, y: y }
With shorthand (the Rust way) this could be simplified to:
Point { x, y }
How?
Update the grammar (notice the optionnal part in a field):
struct_literal -> IDENTIFIER "{" (field ( ("," | ";") field )* ("," | ";")?)? "}" field -> IDENTIFIER ( ":" expression )?
Then if the field is missing, take the identifier as the field name.
What?
Struct literal require to specify the field for each value, even when it is redundant with the name of the variable:
With shorthand (the Rust way) this could be simplified to:
How?
Update the grammar (notice the optionnal part in a field):
Then if the field is missing, take the identifier as the field name.