Re:Announcing Rust 1.19
by shepmaster on Thursday July 20, 2017 @04:20PM
(#14815932)
If you do have the struct implementing `Default`, as suggested from sibling comments, and it's fully public, you can also use the "functional update syntax" (where the `..` is):
In addition, the builder pattern is especially useful for larger configuration objects like this.
[ Parent
| on HN ]
I think the derive_builder crate is worth a mention here:
The main reason I haven't used derive_builder much is that I'd much rather have a compile-time guarantee that all the field that I want are filled out than have to check for an error at runtime (or worse, just `unwrap/expect` everywhere). I'm not sure there's currently a way around this on stable, but I'd personally prefer writing boilerplate for my types than having to handle errors in places that shouldn't need them.