File tree Expand file tree Collapse file tree 1 file changed +14
-16
lines changed Expand file tree Collapse file tree 1 file changed +14
-16
lines changed Original file line number Diff line number Diff line change @@ -2345,24 +2345,22 @@ mod monoids {
2345
2345
}
2346
2346
}
2347
2347
2348
- // WARNING: Panics if self and source are of different `ReductionMonoid` enum entries.
2349
2348
fn clone_from ( & mut self , source : & Self ) {
2350
2349
use ReductionMonoid :: * ;
2351
- match ( self , source) {
2352
- ( Min ( row) , Min ( source_row) ) => {
2353
- row. clone_from ( source_row) ;
2354
- }
2355
- ( Max ( row) , Max ( source_row) ) => {
2356
- row. clone_from ( source_row) ;
2357
- }
2358
- // FIXME(ptravers): not sure what we want to do here we can't overwrite
2359
- // without having owned access to the Row in dest. I don't see a way to
2360
- // achieve that without a clone. Is it better to panic or clone? I would lean
2361
- // clone for safety but I don't know how likely it is to hit the sad case
2362
- // in practice?
2363
- ( dest, src) => soft_panic_or_log ! (
2364
- "Mismatched monoid variants in clone_from! destination: {dest:?} source: {src:?}" ,
2365
- ) ,
2350
+
2351
+ let mut row = match std:: mem:: take ( self ) {
2352
+ Min ( row) | Max ( row) => row,
2353
+ } ;
2354
+
2355
+ let source_row = match source {
2356
+ Min ( row) | Max ( row) => row,
2357
+ } ;
2358
+
2359
+ row. clone_from ( source_row) ;
2360
+
2361
+ match source {
2362
+ Min ( _) => * self = Min ( row) ,
2363
+ Max ( _) => * self = Max ( row) ,
2366
2364
}
2367
2365
}
2368
2366
}
You can’t perform that action at this time.
0 commit comments