and another C++ism that I'd almost forgotten about... what do you mean constructors don't have to initialize every member field? I really used to live like this?

it reminds me a little of the "weekend availability" page on my last company's intranet (which itself was a whole thing i could rant about) that didn't have a checkbox for "not available"

in both cases, you end up with "i consciously didn't fill it in" looking exactly the same as "i forgot to fill it in" and it's impossible to tell what the actual intent was

@luna Just dipping my toes into rust, does this mean constructors have default values? And if so, if the properties aren’t set as mut, does that mean they’re stuck as default values?

@patch @luna To be precise: Rust does not have constructors as such.

Rust has struct initialization syntax, that requires you to initialize all fields. If you want more comoplexity than that, you can offer a factory function that initializes struct values - either based on the factory's parameters, or using default values.

Rust also has struct-update-syntax, that gives you a new struct with the same values as the old one, except for those you explicitly supply.

1/2

@patch @luna
The question if you can mutate a field on a struct depends on how you bind the struct itself. If you bind the struct mutable, you can mutate the fields.

However, usually mutability is not needed, due to the aforementioned struct-update-syntax. If you do not use the original struct afterwards, the compiler usually optimizes away the copy, and uses mutation behind the scenes.

2/2

@soulsource @luna just read that section of the book, thanks for nudging me towards it. :D