Show More
@@ -562,15 +562,15 b' fn merge_copies_dict(' | |||||
562 | MergePick::Major | MergePick::Any => (src_major, src_minor), |
|
562 | MergePick::Major | MergePick::Any => (src_major, src_minor), | |
563 | MergePick::Minor => (src_minor, src_major), |
|
563 | MergePick::Minor => (src_minor, src_major), | |
564 | }; |
|
564 | }; | |
565 |
MergeResult::New |
|
565 | MergeResult::New(CopySource::new_from_merge( | |
566 | current_merge, |
|
566 | current_merge, | |
567 | winner, |
|
567 | winner, | |
568 | loser, |
|
568 | loser, | |
569 | )) |
|
569 | )) | |
570 | } else { |
|
570 | } else { | |
571 | match pick { |
|
571 | match pick { | |
572 |
MergePick::Any | MergePick::Major => MergeResult::Right |
|
572 | MergePick::Any | MergePick::Major => MergeResult::Right, | |
573 |
MergePick::Minor => MergeResult::Left |
|
573 | MergePick::Minor => MergeResult::Left, | |
574 | } |
|
574 | } | |
575 | } |
|
575 | } | |
576 | }) |
|
576 | }) |
@@ -291,9 +291,9 b' fn test_expand_vars() {' | |||||
291 | } |
|
291 | } | |
292 |
|
292 | |||
293 | pub(crate) enum MergeResult<V> { |
|
293 | pub(crate) enum MergeResult<V> { | |
294 |
Left |
|
294 | Left, | |
295 |
Right |
|
295 | Right, | |
296 |
New |
|
296 | New(V), | |
297 | } |
|
297 | } | |
298 |
|
298 | |||
299 | /// Return the union of the two given maps, |
|
299 | /// Return the union of the two given maps, | |
@@ -334,10 +334,10 b' where' | |||||
334 | ordmap_union_with_merge_by_iter(right, left, |key, a, b| { |
|
334 | ordmap_union_with_merge_by_iter(right, left, |key, a, b| { | |
335 | // Also swapped in `merge` arguments: |
|
335 | // Also swapped in `merge` arguments: | |
336 | match merge(key, b, a) { |
|
336 | match merge(key, b, a) { | |
337 |
MergeResult::New |
|
337 | MergeResult::New(v) => MergeResult::New(v), | |
338 | // … and swap back in `merge` result: |
|
338 | // … and swap back in `merge` result: | |
339 |
MergeResult::Left |
|
339 | MergeResult::Left => MergeResult::Right, | |
340 |
MergeResult::Right |
|
340 | MergeResult::Right => MergeResult::Left, | |
341 | } |
|
341 | } | |
342 | }) |
|
342 | }) | |
343 | } else { |
|
343 | } else { | |
@@ -362,11 +362,11 b' where' | |||||
362 | left.insert(key, right_value); |
|
362 | left.insert(key, right_value); | |
363 | } |
|
363 | } | |
364 | Some(left_value) => match merge(&key, left_value, &right_value) { |
|
364 | Some(left_value) => match merge(&key, left_value, &right_value) { | |
365 |
MergeResult::Left |
|
365 | MergeResult::Left => {} | |
366 |
MergeResult::Right |
|
366 | MergeResult::Right => { | |
367 | left.insert(key, right_value); |
|
367 | left.insert(key, right_value); | |
368 | } |
|
368 | } | |
369 |
MergeResult::New |
|
369 | MergeResult::New(new_value) => { | |
370 | left.insert(key, new_value); |
|
370 | left.insert(key, new_value); | |
371 | } |
|
371 | } | |
372 | }, |
|
372 | }, | |
@@ -391,7 +391,7 b' where' | |||||
391 | // TODO: if/when https://github.com/bodil/im-rs/pull/168 is accepted, |
|
391 | // TODO: if/when https://github.com/bodil/im-rs/pull/168 is accepted, | |
392 | // change these from `Vec<(K, V)>` to `Vec<(&K, Cow<V>)>` |
|
392 | // change these from `Vec<(K, V)>` to `Vec<(&K, Cow<V>)>` | |
393 | // with `left_updates` only borrowing from `right` and `right_updates` from |
|
393 | // with `left_updates` only borrowing from `right` and `right_updates` from | |
394 |
// `left`, and with `Cow::Owned` used for `MergeResult::New |
|
394 | // `left`, and with `Cow::Owned` used for `MergeResult::New`. | |
395 | // |
|
395 | // | |
396 | // This would allow moving all `.clone()` calls to after we’ve decided |
|
396 | // This would allow moving all `.clone()` calls to after we’ve decided | |
397 | // which of `right_updates` or `left_updates` to use |
|
397 | // which of `right_updates` or `left_updates` to use | |
@@ -412,13 +412,13 b' where' | |||||
412 | old: (key, left_value), |
|
412 | old: (key, left_value), | |
413 | new: (_, right_value), |
|
413 | new: (_, right_value), | |
414 | } => match merge(key, left_value, right_value) { |
|
414 | } => match merge(key, left_value, right_value) { | |
415 |
MergeResult::Left |
|
415 | MergeResult::Left => { | |
416 | right_updates.push((key.clone(), left_value.clone())) |
|
416 | right_updates.push((key.clone(), left_value.clone())) | |
417 | } |
|
417 | } | |
418 |
MergeResult::Right |
|
418 | MergeResult::Right => { | |
419 | left_updates.push((key.clone(), right_value.clone())) |
|
419 | left_updates.push((key.clone(), right_value.clone())) | |
420 | } |
|
420 | } | |
421 |
MergeResult::New |
|
421 | MergeResult::New(new_value) => { | |
422 | left_updates.push((key.clone(), new_value.clone())); |
|
422 | left_updates.push((key.clone(), new_value.clone())); | |
423 | right_updates.push((key.clone(), new_value)) |
|
423 | right_updates.push((key.clone(), new_value)) | |
424 | } |
|
424 | } |
General Comments 0
You need to be logged in to leave comments.
Login now