##// END OF EJS Templates
rust-utils: strip redundant prefix from enum...
Raphaël Gomès -
r50824:5f1cd683 default
parent child Browse files
Show More
@@ -294,9 +294,9 b' fn test_expand_vars() {'
294 }
294 }
295
295
296 pub(crate) enum MergeResult<V> {
296 pub(crate) enum MergeResult<V> {
297 UseLeftValue,
297 LeftValue,
298 UseRightValue,
298 RightValue,
299 UseNewValue(V),
299 NewValue(V),
300 }
300 }
301
301
302 /// Return the union of the two given maps,
302 /// Return the union of the two given maps,
@@ -337,10 +337,10 b' where'
337 ordmap_union_with_merge_by_iter(right, left, |key, a, b| {
337 ordmap_union_with_merge_by_iter(right, left, |key, a, b| {
338 // Also swapped in `merge` arguments:
338 // Also swapped in `merge` arguments:
339 match merge(key, b, a) {
339 match merge(key, b, a) {
340 MergeResult::UseNewValue(v) => MergeResult::UseNewValue(v),
340 MergeResult::NewValue(v) => MergeResult::NewValue(v),
341 // … and swap back in `merge` result:
341 // … and swap back in `merge` result:
342 MergeResult::UseLeftValue => MergeResult::UseRightValue,
342 MergeResult::LeftValue => MergeResult::RightValue,
343 MergeResult::UseRightValue => MergeResult::UseLeftValue,
343 MergeResult::RightValue => MergeResult::LeftValue,
344 }
344 }
345 })
345 })
346 } else {
346 } else {
@@ -365,8 +365,8 b' where'
365 left.insert(key, right_value);
365 left.insert(key, right_value);
366 }
366 }
367 Some(left_value) => match merge(&key, left_value, &right_value) {
367 Some(left_value) => match merge(&key, left_value, &right_value) {
368 MergeResult::UseLeftValue => {}
368 MergeResult::LeftValue => {}
369 MergeResult::UseRightValue => {
369 MergeResult::RightValue => {
370 left.insert(key, right_value);
370 left.insert(key, right_value);
371 }
371 }
372 MergeResult::UseNewValue(new_value) => {
372 MergeResult::UseNewValue(new_value) => {
@@ -394,7 +394,7 b' where'
394 // TODO: if/when https://github.com/bodil/im-rs/pull/168 is accepted,
394 // TODO: if/when https://github.com/bodil/im-rs/pull/168 is accepted,
395 // change these from `Vec<(K, V)>` to `Vec<(&K, Cow<V>)>`
395 // change these from `Vec<(K, V)>` to `Vec<(&K, Cow<V>)>`
396 // with `left_updates` only borrowing from `right` and `right_updates` from
396 // with `left_updates` only borrowing from `right` and `right_updates` from
397 // `left`, and with `Cow::Owned` used for `MergeResult::UseNewValue`.
397 // `left`, and with `Cow::Owned` used for `MergeResult::NewValue`.
398 //
398 //
399 // This would allow moving all `.clone()` calls to after we’ve decided
399 // This would allow moving all `.clone()` calls to after we’ve decided
400 // which of `right_updates` or `left_updates` to use
400 // which of `right_updates` or `left_updates` to use
@@ -415,13 +415,13 b' where'
415 old: (key, left_value),
415 old: (key, left_value),
416 new: (_, right_value),
416 new: (_, right_value),
417 } => match merge(key, left_value, right_value) {
417 } => match merge(key, left_value, right_value) {
418 MergeResult::UseLeftValue => {
418 MergeResult::LeftValue => {
419 right_updates.push((key.clone(), left_value.clone()))
419 right_updates.push((key.clone(), left_value.clone()))
420 }
420 }
421 MergeResult::UseRightValue => {
421 MergeResult::RightValue => {
422 left_updates.push((key.clone(), right_value.clone()))
422 left_updates.push((key.clone(), right_value.clone()))
423 }
423 }
424 MergeResult::UseNewValue(new_value) => {
424 MergeResult::NewValue(new_value) => {
425 left_updates.push((key.clone(), new_value.clone()));
425 left_updates.push((key.clone(), new_value.clone()));
426 right_updates.push((key.clone(), new_value))
426 right_updates.push((key.clone(), new_value))
427 }
427 }
General Comments 0
You need to be logged in to leave comments. Login now