Hello Rust friends. Is it bad to implement Add and then use this boilerplate for AddAssign? impl AddAssign for Foo { fn add_assign(&mut self, rhs: Self) { *self = *self + rhs; } }
-
-
TBH your match is probably more clear than any named function could be. I'd bet the context for what this is being used for is pretty helpful to understanding why this needs to do what it does
-
The context is like this: let begin_at = combine_opt(self.begin_at, rhs.begin_at, std::cmp::min); let end_at = combine_opt(self.end_at, rhs.end_at, std::cmp::max);
- 7 more replies
New conversation -
-
-
No worries. You could do it with an xor first but that wouldn't be very elegant, I think.
-
lhs.xor(rhs).or(option::zip_with(lhs, rhs, f)) or some such
- 2 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.