Hi all,
Is it possible to extend record types with new fields in Rust without
indirection? Say i have a
type point2d = {x: int, y: int};
and i'd like to create a new record type the addition of field z
type point3d = {x: int, y: int, z: int}
I would like to write something like
type point3d = {type point2d, z: int}
because with records that contain many fields it will become annoying
to write down all fields when defining a new record type with
additional fields.
Related is the record update syntax. Currently you can create new
records that have the same type as the existing record
let oldpoint = {x: 10, y: 20};
let newpoint = {x: 30 with oldpoint};
Say i have a record that functions as a prototype for other records.
let person = {first_name: "John", last_name: "Doe"};
It would be nice to be able to create an extended record like this
let patient: {memory_loss: true with person};
The new fields in the record expression would then be added after the
existing fields of the prototype record resulting in record type
{first_name: str, last_name: str, memory_loss: bool}
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev