diff rust/hg-core/src/utils.rs @ 49930:e98fd81bb151

rust-clippy: fix most warnings in `hg-core` All of these are simple changes that for the most part are clear improvements and the rest are at most equivalent. The remaining warnings have to be fixed either with a bigger refactor like for the nested "revlog" module, or in the dependency `bytes-cast`, which we own. This will be done sometime in the future.
author Raphaël Gomès <rgomes@octobus.net>
date Mon, 09 Jan 2023 19:18:43 +0100
parents 5f1cd6839c69
children 83437ad8fe3d
line wrap: on
line diff
--- a/rust/hg-core/src/utils.rs	Mon Jan 09 19:14:14 2023 +0100
+++ b/rust/hg-core/src/utils.rs	Mon Jan 09 19:18:43 2023 +0100
@@ -137,11 +137,8 @@
     }
 
     fn split_2_by_slice(&self, separator: &[u8]) -> Option<(&[u8], &[u8])> {
-        if let Some(pos) = find_slice_in_slice(self, separator) {
-            Some((&self[..pos], &self[pos + separator.len()..]))
-        } else {
-            None
-        }
+        find_slice_in_slice(self, separator)
+            .map(|pos| (&self[..pos], &self[pos + separator.len()..]))
     }
 }
 
@@ -369,7 +366,7 @@
                 MergeResult::RightValue => {
                     left.insert(key, right_value);
                 }
-                MergeResult::UseNewValue(new_value) => {
+                MergeResult::NewValue(new_value) => {
                     left.insert(key, new_value);
                 }
             },