all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Shannon Sterz <s.sterz@proxmox.com>
To: yew-devel@lists.proxmox.com
Subject: [yew-devel] [PATCH proxmox-yew-comp] object-grid/tasks: replace match statements with `?`
Date: Mon, 13 Jan 2025 12:04:02 +0100	[thread overview]
Message-ID: <20250113110402.151879-1-s.sterz@proxmox.com> (raw)

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


             reply	other threads:[~2025-01-13 11:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-13 11:04 Shannon Sterz [this message]
2025-01-13 12:09 ` [yew-devel] applied: " 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=20250113110402.151879-1-s.sterz@proxmox.com \
    --to=s.sterz@proxmox.com \
    --cc=yew-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal