sway
sway copied to clipboard
Structual records?
The idea here is that we would add structural records to the language.
I proposed this initially as an addition to Rust (see https://github.com/rust-lang/rfcs/pull/2584), but it was never added, mainly due to a large backlog of other features to implement.
The proposed syntax is exactly as that in Rust, in expression, pattern, and type contexts alike.
So for example, you could write { foo: 42, bar: true, baz: "abcd" },
and this would be typed as { foo: u64, bar: bool, baz: str[4] }.
Note that structural records would be added alongside structs, as a convenience, but not to replace them.