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; } }
-
Show this thread
-
Ok, here's another one. Does this monoidal crush for options exist somewhere? I guess you could do something with xor and zip_wiith but it wouldn't be pretty. https://gist.github.com/reinh/1d8ba34b3f9a1bbe6eff0f1e1e6e7754 …pic.twitter.com/ldGabIwlaA
2 replies 0 retweets 5 likesShow this thread -
-
Replying to @sgrif
zip would throw away the Some in the Some + None cases, right?
1 reply 0 retweets 0 likes -
-
Replying to @sgrif
No worries. You could do it with an xor first but that wouldn't be very elegant, I think.
2 replies 0 retweets 0 likes
Replying to @ReinH
Yeah, `a.xor(b).or_else(|| prev_tweet)` would do it. I'd lean towards the match over that though
2:44 PM - 28 Jul 2020
0 replies
0 retweets
0 likes
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.