# HG changeset patch # User Raphaël Gomès # Date 1673288054 -3600 # Node ID 5f1cd6839c69321d60732f63b4b55002ff8a25fe # Parent ccb6cfb0f2c05c4817394c0662066921d5f9f6ce rust-utils: strip redundant prefix from enum This was highlighted by `clippy`, I think this makes the code cleaner. diff -r ccb6cfb0f2c0 -r 5f1cd6839c69 rust/hg-core/src/utils.rs --- a/rust/hg-core/src/utils.rs Mon Jan 09 19:07:44 2023 +0100 +++ b/rust/hg-core/src/utils.rs Mon Jan 09 19:14:14 2023 +0100 @@ -294,9 +294,9 @@ } pub(crate) enum MergeResult { - UseLeftValue, - UseRightValue, - UseNewValue(V), + LeftValue, + RightValue, + NewValue(V), } /// Return the union of the two given maps, @@ -337,10 +337,10 @@ ordmap_union_with_merge_by_iter(right, left, |key, a, b| { // Also swapped in `merge` arguments: match merge(key, b, a) { - MergeResult::UseNewValue(v) => MergeResult::UseNewValue(v), + MergeResult::NewValue(v) => MergeResult::NewValue(v), // … and swap back in `merge` result: - MergeResult::UseLeftValue => MergeResult::UseRightValue, - MergeResult::UseRightValue => MergeResult::UseLeftValue, + MergeResult::LeftValue => MergeResult::RightValue, + MergeResult::RightValue => MergeResult::LeftValue, } }) } else { @@ -365,8 +365,8 @@ left.insert(key, right_value); } Some(left_value) => match merge(&key, left_value, &right_value) { - MergeResult::UseLeftValue => {} - MergeResult::UseRightValue => { + MergeResult::LeftValue => {} + MergeResult::RightValue => { left.insert(key, right_value); } MergeResult::UseNewValue(new_value) => { @@ -394,7 +394,7 @@ // TODO: if/when https://github.com/bodil/im-rs/pull/168 is accepted, // change these from `Vec<(K, V)>` to `Vec<(&K, Cow)>` // with `left_updates` only borrowing from `right` and `right_updates` from - // `left`, and with `Cow::Owned` used for `MergeResult::UseNewValue`. + // `left`, and with `Cow::Owned` used for `MergeResult::NewValue`. // // This would allow moving all `.clone()` calls to after we’ve decided // which of `right_updates` or `left_updates` to use @@ -415,13 +415,13 @@ old: (key, left_value), new: (_, right_value), } => match merge(key, left_value, right_value) { - MergeResult::UseLeftValue => { + MergeResult::LeftValue => { right_updates.push((key.clone(), left_value.clone())) } - MergeResult::UseRightValue => { + MergeResult::RightValue => { left_updates.push((key.clone(), right_value.clone())) } - MergeResult::UseNewValue(new_value) => { + MergeResult::NewValue(new_value) => { left_updates.push((key.clone(), new_value.clone())); right_updates.push((key.clone(), new_value)) }