3 ms·
> Item 8: Use builders for complex types Hmm. > The boilerplate can be significantly reduced by implementing and using the Default trait, as described in Item
by twic 3y ago
> Item 8: Use builders for complex types
Hmm.
> The boilerplate can be significantly reduced by implementing and using the Default trait, as described in Item 5:
Yes, standard and good advice.
> That's a more general concern: the automatically derived implementation of Default only works if all of the field types implement the Default trait. If there's a field that doesn't play along, the derive step doesn't work:
> The code can't implement Default for chrono::Utc because of the orphan rule, so this means that
... you have to implement Default for your struct manually.
> all of the fields have to be filled out manually:
What?
> These ergonomics can be improved if you implement the builder pattern for complex data structures.
No!
Does this document contain actually good advice, or is this just some guy's thoughts?