Hi there!
I've got a project that needs to speak to an existing database. Ids are assigned by the database, so during the code paths where the object hasn't been saved I have structs like:
pub struct User {
email: String,
first_name: String,
...
}
In some of the code paths after the user saved, the id is needed, so I have a lot of duplicate structs where the only extra field is an id: u32
.
Is there a way to keep from duplicating all the fields in another struct? For example, in TypeScript, I can use type unions to combine two types using TypeA & TypeB
.
Thanks!