slint
slint copied to clipboard
Default values for struct fields
It is often requested to have default values for struct fields
It could look like this:
struct Player {
score: int = -1,
name: string = "John Smith",
}
Then, when initialized, or converted from a struct with less fields, the other fields are initialized with thei default value:
component X {
// initialized to default values
property <Player> player1;
// score will be -1
property <Player> player2: { name: "Alex" };
}
The Default implementation of the rust structure or C++ default constructor must initialize the fields accordingly.