pattern

Builder pattern in Rust

https://rust-unofficial.github.io/patterns/patterns/creational/builder.html TL;DR Construct an object with calls to a builder helper. Explain with Rust example: step by step I guess this Pasta example is a bad example… need to be improved Suppose you define a new struct (I use &str because it is just a snippet, but in real code, you should use String in this case): struct Pasta<'a> { name: &'a str, tomato: bool, garlic: bool, special_order: &'a str } You can create/initialize an object like below: