From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <yew-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id 7A3641FF173
	for <inbox@lore.proxmox.com>; Mon, 13 Jan 2025 12:05:05 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 5038D2C4BA;
	Mon, 13 Jan 2025 12:04:49 +0100 (CET)
From: Shannon Sterz <s.sterz@proxmox.com>
To: yew-devel@lists.proxmox.com
Date: Mon, 13 Jan 2025 12:04:02 +0100
Message-Id: <20250113110402.151879-1-s.sterz@proxmox.com>
X-Mailer: git-send-email 2.39.5
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL -1.335 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
 URIBL_DBL_SPAM 2.5 Contains a spam URL listed in the Spamhaus DBL blocklist
 [tasks.rs]
 URIBL_SBL_A 0.1 Contains URL's A record listed in the Spamhaus SBL blocklist
 [185.199.111.153, 185.199.108.153, 185.199.109.153, 185.199.110.153]
Subject: [yew-devel] [PATCH proxmox-yew-comp] object-grid/tasks: replace
 match statements with `?`
X-BeenThere: yew-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Yew framework devel list at Proxmox <yew-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/yew-devel>, 
 <mailto:yew-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/yew-devel/>
List-Post: <mailto:yew-devel@lists.proxmox.com>
List-Help: <mailto:yew-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel>, 
 <mailto:yew-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Yew framework devel list at Proxmox <yew-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: yew-devel-bounces@lists.proxmox.com
Sender: "yew-devel" <yew-devel-bounces@lists.proxmox.com>

this makes the code more succinct and fixes the clippy lint
`question_mark` [1].

[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#question_mark

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
 src/object_grid.rs | 16 +++-------------
 src/tasks.rs       | 10 ++--------
 2 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/src/object_grid.rs b/src/object_grid.rs
index b922f02..a6313d0 100644
--- a/src/object_grid.rs
+++ b/src/object_grid.rs
@@ -303,25 +303,15 @@ impl PwtObjectGrid {
     fn edit_dialog(&self, ctx: &LoadableComponentContext<Self>) -> Option<Html> {
         let props = ctx.props();
 
-        let name = match self.selection.as_ref() {
-            Some(name) => name.to_string(),
-            None => return None,
-        };
-
-        let row = match self.rows.iter().find(|row| row.name == name) {
-            Some(row) => row,
-            None => return None,
-        };
+        let name = self.selection.as_ref()?.to_string();
+        let row = self.rows.iter().find(|row| row.name == name)?;
 
         let title = &row.header;
 
         let data = self.data.clone();
         let value = data[&name].clone();
 
-        let editor = match self.editors.get(&name) {
-            Some(editor) => editor.clone(),
-            None => return None,
-        };
+        let editor = self.editors.get(&name)?.clone();
 
         Some(
             EditWindow::new(format!("Edit: {}", title))
diff --git a/src/tasks.rs b/src/tasks.rs
index 0286527..9a6ad63 100644
--- a/src/tasks.rs
+++ b/src/tasks.rs
@@ -274,14 +274,8 @@ impl LoadableComponent for ProxmoxTasks {
     ) -> Option<Html> {
         let props = ctx.props();
 
-        let selected_key = match self.selection.selected_key() {
-            Some(key) => key, // upid
-            None => return None,
-        };
-        let selected_item = match self.store.read().lookup_record(&selected_key) {
-            Some(item) => item.clone(),
-            None => return None,
-        };
+        let selected_key = self.selection.selected_key()?;
+        let selected_item = self.store.read().lookup_record(&selected_key)?.clone();
 
         match view_state {
             ViewDialog::TaskViewer => {
-- 
2.39.5



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