Sorry, I am assuming familiarity/conflating with the prior discussion at
The idea in that thread evolved to the ability to write
struct Foo {
mandatory: Type,
optional: Type = Type::default(),
}
fn main() {
let _ = Foo { mandatory: Type::foo(), .. };
}
which is something that can't be accomplished with Default
because you can't have partially initialized values in Rust. Adding this syntax along with the semantics described in the linked post reduces the need of crates writing builders in their APIs. If such feature is added to the language, then leveraging that new syntax from derive(Default)
makes sense in my eyes. If partially defaulted values are never adopted, then instead going for a field attribute that derive(Default)
consumes and rejecting new syntax would indeed make more sense.