3 ms·
It gets awkward really fast when you may need to set a value. let mut foo = build_foo() .with_a(8); if need_to_set_b { foo = foo.with_
by kevincox 4y ago
It gets awkward really fast when you may need to set a value.
let mut foo = build_foo()
.with_a(8);
if need_to_set_b {
foo = foo.with_b(false);
}
let foo = foo.build();
- maxbond 4y agoWould look very similar with named arguments, no?
- kevincox 4y agoMaybe. It depends a bit on how they are implemented. If there is a good way to pass "default" then you can just have a condition for that one argument. But if there is no way to pass "default" then it can get hairy.
- maxbond 4y agoFor sure. I would like to see that in Rust as well, that would be nice. I am willing to put up with the lack of variadic & named arguments for the goodness the borrow checker brings me, but I can see how that would improve the ergonomics substantially.
- svieira 4y agoNot if you do what Dart did: https://medium.com/dartlang/making-dart-a-better-language-for-ui-f1ccaf9f546c https://medium.com/dartlang/making-dart-a-better-language-fo...