all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [yew-devel] [PATCH proxmox-yew-comp] object-grid/tasks: replace match statements with `?`
@ 2025-01-13 11:04 Shannon Sterz
  2025-01-13 12:09 ` [yew-devel] applied: " Dietmar Maurer
  0 siblings, 1 reply; 2+ messages in thread
From: Shannon Sterz @ 2025-01-13 11:04 UTC (permalink / raw)
  To: yew-devel

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [yew-devel] applied: [PATCH proxmox-yew-comp] object-grid/tasks: replace match statements with `?`
  2025-01-13 11:04 [yew-devel] [PATCH proxmox-yew-comp] object-grid/tasks: replace match statements with `?` Shannon Sterz
@ 2025-01-13 12:09 ` Dietmar Maurer
  0 siblings, 0 replies; 2+ messages in thread
From: Dietmar Maurer @ 2025-01-13 12:09 UTC (permalink / raw)
  To: Yew framework devel list at Proxmox, Shannon Sterz

applied


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-01-13 12:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-13 11:04 [yew-devel] [PATCH proxmox-yew-comp] object-grid/tasks: replace match statements with `?` Shannon Sterz
2025-01-13 12:09 ` [yew-devel] applied: " Dietmar Maurer

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