rust-unofficial / patterns

A catalogue of Rust design patterns, anti-patterns and idioms
https://rust-unofficial.github.io/patterns/
Mozilla Public License 2.0
7.98k stars 363 forks source link

Make builder pattern more practical #90

Closed tgotwig closed 3 years ago

tgotwig commented 4 years ago

https://github.com/TGotwig/patterns/blob/patch-1/patterns/builder.md

nesteruk commented 4 years ago

It is confusing to have bar: String in both Foo and FooBuilder — consider renaming one of the bars to something else.

tgotwig commented 4 years ago

@nesteruk Changed this and a little bit more 🙂

pickfire commented 4 years ago

This example does not seemed to be explaining much, maybe we could have a real-life example or an explanation on why it needs to be constructed this way rather than just specifying the struct directly?

tgotwig commented 3 years ago

@pickfire Hmm, changed it a little bit up. I think that runnable code is better than not runnable code and the comments should explain enough 🧐

simonsan commented 3 years ago

@TGotwig Hey, thank you for the PR. Could you please rebase on master so the CI is checking this through while we get to reviewing this PR? Thank you ;-)

tgotwig commented 3 years ago

@simonsan Sure, will do! 😃

simonsan commented 3 years ago

@simonsan Sure, will do! 😃

Sorry, haven't seen that there is no addition to summary or anything needed. So I could do it myself. ;-) It's fine then.

simonsan commented 3 years ago

@MarcoIeni You also want to look over it again?

simonsan commented 3 years ago

Thanks! :-)

tgotwig commented 3 years ago

Cool! 😊🚀