changeset 49934:83437ad8fe3d

rust-clippy: remove redundant suffix from enum Same as last time, this makes the code clearer in this instance.
author Raphaël Gomès <rgomes@octobus.net>
date Tue, 10 Jan 2023 10:41:52 +0100
parents be3b545c5cff
children da02e88b4850
files rust/hg-core/src/copy_tracing.rs rust/hg-core/src/utils.rs
diffstat 2 files changed, 16 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/copy_tracing.rs	Mon Jan 09 19:37:05 2023 +0100
+++ b/rust/hg-core/src/copy_tracing.rs	Tue Jan 10 10:41:52 2023 +0100
@@ -562,15 +562,15 @@
                 MergePick::Major | MergePick::Any => (src_major, src_minor),
                 MergePick::Minor => (src_minor, src_major),
             };
-            MergeResult::NewValue(CopySource::new_from_merge(
+            MergeResult::New(CopySource::new_from_merge(
                 current_merge,
                 winner,
                 loser,
             ))
         } else {
             match pick {
-                MergePick::Any | MergePick::Major => MergeResult::RightValue,
-                MergePick::Minor => MergeResult::LeftValue,
+                MergePick::Any | MergePick::Major => MergeResult::Right,
+                MergePick::Minor => MergeResult::Left,
             }
         }
     })
--- a/rust/hg-core/src/utils.rs	Mon Jan 09 19:37:05 2023 +0100
+++ b/rust/hg-core/src/utils.rs	Tue Jan 10 10:41:52 2023 +0100
@@ -291,9 +291,9 @@
 }
 
 pub(crate) enum MergeResult<V> {
-    LeftValue,
-    RightValue,
-    NewValue(V),
+    Left,
+    Right,
+    New(V),
 }
 
 /// Return the union of the two given maps,
@@ -334,10 +334,10 @@
         ordmap_union_with_merge_by_iter(right, left, |key, a, b| {
             // Also swapped in `merge` arguments:
             match merge(key, b, a) {
-                MergeResult::NewValue(v) => MergeResult::NewValue(v),
+                MergeResult::New(v) => MergeResult::New(v),
                 // … and swap back in `merge` result:
-                MergeResult::LeftValue => MergeResult::RightValue,
-                MergeResult::RightValue => MergeResult::LeftValue,
+                MergeResult::Left => MergeResult::Right,
+                MergeResult::Right => MergeResult::Left,
             }
         })
     } else {
@@ -362,11 +362,11 @@
                 left.insert(key, right_value);
             }
             Some(left_value) => match merge(&key, left_value, &right_value) {
-                MergeResult::LeftValue => {}
-                MergeResult::RightValue => {
+                MergeResult::Left => {}
+                MergeResult::Right => {
                     left.insert(key, right_value);
                 }
-                MergeResult::NewValue(new_value) => {
+                MergeResult::New(new_value) => {
                     left.insert(key, new_value);
                 }
             },
@@ -391,7 +391,7 @@
     // TODO: if/when https://github.com/bodil/im-rs/pull/168 is accepted,
     // change these from `Vec<(K, V)>` to `Vec<(&K, Cow<V>)>`
     // with `left_updates` only borrowing from `right` and `right_updates` from
-    // `left`, and with `Cow::Owned` used for `MergeResult::NewValue`.
+    // `left`, and with `Cow::Owned` used for `MergeResult::New`.
     //
     // This would allow moving all `.clone()` calls to after we’ve decided
     // which of `right_updates` or `left_updates` to use
@@ -412,13 +412,13 @@
                 old: (key, left_value),
                 new: (_, right_value),
             } => match merge(key, left_value, right_value) {
-                MergeResult::LeftValue => {
+                MergeResult::Left => {
                     right_updates.push((key.clone(), left_value.clone()))
                 }
-                MergeResult::RightValue => {
+                MergeResult::Right => {
                     left_updates.push((key.clone(), right_value.clone()))
                 }
-                MergeResult::NewValue(new_value) => {
+                MergeResult::New(new_value) => {
                     left_updates.push((key.clone(), new_value.clone()));
                     right_updates.push((key.clone(), new_value))
                 }