[pbs-devel] [PATCH backup 5/5] replace match statements with ? operator

Maximiliano Sandoval m.sandoval at proxmox.com
Mon Jan 13 14:25:53 CET 2025


When possible.

Signed-off-by: Maximiliano Sandoval <m.sandoval at proxmox.com>
---
 pbs-config/src/acl.rs          | 10 ++--------
 pbs-datastore/src/hierarchy.rs |  7 +++----
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/pbs-config/src/acl.rs b/pbs-config/src/acl.rs
index e8690560..aca1f68f 100644
--- a/pbs-config/src/acl.rs
+++ b/pbs-config/src/acl.rs
@@ -342,10 +342,7 @@ impl AclTree {
         let mut node = &self.root;
         for outer in path {
             for comp in outer.split('/') {
-                node = match node.children.get(comp) {
-                    Some(n) => n,
-                    None => return None,
-                };
+                node = node.children.get(comp)?;
             }
         }
         Some(node)
@@ -355,10 +352,7 @@ impl AclTree {
         let mut node = &mut self.root;
         for outer in path {
             for comp in outer.split('/') {
-                node = match node.children.get_mut(comp) {
-                    Some(n) => n,
-                    None => return None,
-                };
+                node = node.children.get_mut(comp)?;
             }
         }
         Some(node)
diff --git a/pbs-datastore/src/hierarchy.rs b/pbs-datastore/src/hierarchy.rs
index 8b7af038..25a4d382 100644
--- a/pbs-datastore/src/hierarchy.rs
+++ b/pbs-datastore/src/hierarchy.rs
@@ -417,10 +417,9 @@ impl Iterator for ListNamespacesRecursive {
                 if state.is_empty() {
                     return None; // there's a state but it's empty -> we're all done
                 }
-                let iter = match state.last_mut() {
-                    Some(iter) => iter,
-                    None => return None, // unexpected, should we just unwrap?
-                };
+                // should we just unwrap on None?
+                let iter = state.last_mut()?;
+
                 match iter.next() {
                     Some(Ok(ns)) => {
                         if state.len() < self.max_depth as usize {
-- 
2.39.5





More information about the pbs-devel mailing list