changeset 51271:eab5b061cd48

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.
author Raphaël Gomès <rgomes@octobus.net>
date Wed, 20 Dec 2023 14:58:36 +0100
parents ceeb8fa23cc8
children c4cbb515b006
files rust/rhg/src/commands/status.rs
diffstat 1 files changed, 37 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- 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)?;