public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH backup 5/5] replace match statements with ? operator
Date: Mon, 13 Jan 2025 14:25:53 +0100	[thread overview]
Message-ID: <20250113132553.435319-5-m.sandoval@proxmox.com> (raw)
In-Reply-To: <20250113132553.435319-1-m.sandoval@proxmox.com>

When possible.

Signed-off-by: Maximiliano Sandoval <m.sandoval@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



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


  parent reply	other threads:[~2025-01-13 13:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-13 13:25 [pbs-devel] [PATCH backup 1/5] backup: remove unneded import Maximiliano Sandoval
2025-01-13 13:25 ` [pbs-devel] [PATCH backup 2/5] metric_collection: remove redundant map_or Maximiliano Sandoval
2025-01-13 13:25 ` [pbs-devel] [PATCH backup 3/5] elide lifetimes when possible Maximiliano Sandoval
2025-01-13 13:25 ` [pbs-devel] [PATCH backup 4/5] sg_pt_changer: remove needless call to as_bytes() Maximiliano Sandoval
2025-01-13 13:25 ` Maximiliano Sandoval [this message]
2025-01-14  7:59 ` [pbs-devel] applied: [PATCH backup 1/5] backup: remove unneded import Dietmar Maurer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250113132553.435319-5-m.sandoval@proxmox.com \
    --to=m.sandoval@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal