File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,9 @@ Prevents proliferation of constructors.
7373
7474Can be used for one-liner initialisation as well as more complex construction.
7575
76+ When you add new fields to the target struct, you can update the builder to
77+ leave client code backwards compatible.
78+
7679## Disadvantages
7780
7881More complex than creating a struct object directly, or a simple constructor
@@ -81,9 +84,9 @@ function.
8184## Discussion
8285
8386This pattern is seen more frequently in Rust (and for simpler objects) than in
84- many other languages because Rust lacks overloading. Since you can only have a
85- single method with a given name, having multiple constructors is less nice in
86- Rust than in C++, Java, or others.
87+ many other languages because Rust lacks overloading and default values for
88+ function parameters. Since you can only have a single method with a given name,
89+ having multiple constructors is less nice in Rust than in C++, Java, or others.
8790
8891This pattern is often used where the builder object is useful in its own right,
8992rather than being just a builder. For example, see
You can’t perform that action at this time.
0 commit comments