rust-clippy: simplify `match` to `if let`
authorRaphaël Gomès <rgomes@octobus.net>
Wed, 20 Dec 2023 14:58:36 +0100
changeset 51271 eab5b061cd48
parent 51270 ceeb8fa23cc8
child 51272 c4cbb515b006
rust-clippy: simplify `match` to `if let` This was hinted at by clippy, and makes it more obvious that nothing is happening in the `None` case.
rust/rhg/src/commands/status.rs
--- a/rust/rhg/src/commands/status.rs	Fri Dec 01 22:56:08 2023 +0100
+++ b/rust/rhg/src/commands/status.rs	Wed Dec 20 14:58:36 2023 +0100
@@ -446,54 +446,51 @@
     };
     let (narrow_matcher, narrow_warnings) = narrow::matcher(repo)?;
 
-    match revpair {
-        Some((rev1, rev2)) => {
-            let mut ds_status = DirstateStatus::default();
-            if list_copies {
-                return Err(CommandError::unsupported(
-                    "status --rev --rev with copy information is not implemented yet",
-                ));
-            }
+    if let Some((rev1, rev2)) = revpair {
+        let mut ds_status = DirstateStatus::default();
+        if list_copies {
+            return Err(CommandError::unsupported(
+                "status --rev --rev with copy information is not implemented yet",
+            ));
+        }
 
-            let stat = hg::operations::status_rev_rev_no_copies(
-                repo,
-                rev1,
-                rev2,
-                narrow_matcher,
-            )?;
-            for entry in stat.iter() {
-                let (path, status) = entry?;
-                let path = StatusPath {
-                    path: Cow::Borrowed(path),
-                    copy_source: None,
-                };
-                match status {
-                    hg::operations::DiffStatus::Removed => {
-                        if display_states.removed {
-                            ds_status.removed.push(path)
-                        }
+        let stat = hg::operations::status_rev_rev_no_copies(
+            repo,
+            rev1,
+            rev2,
+            narrow_matcher,
+        )?;
+        for entry in stat.iter() {
+            let (path, status) = entry?;
+            let path = StatusPath {
+                path: Cow::Borrowed(path),
+                copy_source: None,
+            };
+            match status {
+                hg::operations::DiffStatus::Removed => {
+                    if display_states.removed {
+                        ds_status.removed.push(path)
                     }
-                    hg::operations::DiffStatus::Added => {
-                        if display_states.added {
-                            ds_status.added.push(path)
-                        }
+                }
+                hg::operations::DiffStatus::Added => {
+                    if display_states.added {
+                        ds_status.added.push(path)
                     }
-                    hg::operations::DiffStatus::Modified => {
-                        if display_states.modified {
-                            ds_status.modified.push(path)
-                        }
+                }
+                hg::operations::DiffStatus::Modified => {
+                    if display_states.modified {
+                        ds_status.modified.push(path)
                     }
-                    hg::operations::DiffStatus::Matching => {
-                        if display_states.clean {
-                            ds_status.clean.push(path)
-                        }
+                }
+                hg::operations::DiffStatus::Matching => {
+                    if display_states.clean {
+                        ds_status.clean.push(path)
                     }
                 }
             }
-            output.output(display_states, ds_status)?;
-            return Ok(());
         }
-        None => (),
+        output.output(display_states, ds_status)?;
+        return Ok(());
     }
 
     let (sparse_matcher, sparse_warnings) = sparse::matcher(repo)?;