From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 7BB1F1FF173 for ; Mon, 13 Jan 2025 14:26:17 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E7B012F475; Mon, 13 Jan 2025 14:25:57 +0100 (CET) From: Maximiliano Sandoval To: pbs-devel@lists.proxmox.com Date: Mon, 13 Jan 2025 14:25:53 +0100 Message-Id: <20250113132553.435319-5-m.sandoval@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250113132553.435319-1-m.sandoval@proxmox.com> References: <20250113132553.435319-1-m.sandoval@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.103 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH backup 5/5] replace match statements with ? operator X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" When possible. Signed-off-by: Maximiliano Sandoval --- 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