public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pdm-devel] [PATCH proxmox-yew-comp 01/15] remove needless borrows
@ 2025-01-13 14:27 Maximiliano Sandoval
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 02/15] remove needless casts Maximiliano Sandoval
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: Maximiliano Sandoval @ 2025-01-13 14:27 UTC (permalink / raw)
  To: pdm-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 src/apt_package_manager.rs        | 2 +-
 src/apt_repositories.rs           | 6 +++---
 src/configuration/network_edit.rs | 2 +-
 src/configuration/network_view.rs | 2 +-
 src/form/mod.rs                   | 2 +-
 src/rrd_graph_new.rs              | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/apt_package_manager.rs b/src/apt_package_manager.rs
index 6e0d677..5171d81 100644
--- a/src/apt_package_manager.rs
+++ b/src/apt_package_manager.rs
@@ -237,7 +237,7 @@ impl LoadableComponent for ProxmoxAptPackageManager {
     ) -> Option<Html> {
         match view_state {
             ViewState::ShowChangelog(package) => {
-                Some(self.create_show_changelog_dialog(ctx, &package))
+                Some(self.create_show_changelog_dialog(ctx, package))
             }
         }
     }
diff --git a/src/apt_repositories.rs b/src/apt_repositories.rs
index c92665e..bf308bd 100644
--- a/src/apt_repositories.rs
+++ b/src/apt_repositories.rs
@@ -213,7 +213,7 @@ fn update_status_store(
                 if check_mixed_suites
                     && repo.enabled
                     && repo.types.contains(&APTRepositoryPackageType::Deb)
-                    && controlled_origin.contains(&(&path, index))
+                    && controlled_origin.contains(&(path, index))
                 {
                     mixed_suites = true;
                 }
@@ -474,7 +474,7 @@ impl LoadableComponent for ProxmoxAptRepositories {
                     update_status_store(
                         props.product,
                         &self.status_store,
-                        &config,
+                        config,
                         &self.standard_repos,
                         active_subscription,
                     );
@@ -503,7 +503,7 @@ impl LoadableComponent for ProxmoxAptRepositories {
                 self.standard_repos = standard_repos.clone();
 
                 self.validate_standard_repo = ValidateFn::new(move |(repo, _): &(String, _)| {
-                    let (_, _, enabled) = standard_repo_info(&standard_repos, &repo);
+                    let (_, _, enabled) = standard_repo_info(&standard_repos, repo);
                     if enabled {
                         Err(Error::msg(tr!("Already configured")))
                     } else {
diff --git a/src/configuration/network_edit.rs b/src/configuration/network_edit.rs
index 5629da9..010dc30 100644
--- a/src/configuration/network_edit.rs
+++ b/src/configuration/network_edit.rs
@@ -61,7 +61,7 @@ async fn create_item(
         }
     }
 
-    data["type"] = serde_json::to_value(&interface_type).unwrap();
+    data["type"] = serde_json::to_value(interface_type).unwrap();
 
     crate::http_post("/nodes/localhost/network", Some(data)).await
 }
diff --git a/src/configuration/network_view.rs b/src/configuration/network_view.rs
index 5cc0d68..c56d97c 100644
--- a/src/configuration/network_view.rs
+++ b/src/configuration/network_view.rs
@@ -36,7 +36,7 @@ async fn load_interfaces() -> Result<(Vec<Interface>, String), Error> {
 async fn delete_interface(key: Key) -> Result<(), Error> {
     let url = format!(
         "/nodes/localhost/network/{}",
-        percent_encode_component(&*key)
+        percent_encode_component(&key)
     );
     crate::http_delete(&url, None).await?;
     Ok(())
diff --git a/src/form/mod.rs b/src/form/mod.rs
index 9661c28..0b9d8a9 100644
--- a/src/form/mod.rs
+++ b/src/form/mod.rs
@@ -16,7 +16,7 @@ fn format_property(name: &str, part: &str) -> String {
 /// to expose a property to the UI, simply add a hidden field to the form.
 pub fn flatten_property_string(data: &mut Value, name: &str, schema: &'static Schema) {
     if let Some(prop_str) = data[name].as_str() {
-        if let Ok(Value::Object(map)) = schema.parse_property_string(&prop_str) {
+        if let Ok(Value::Object(map)) = schema.parse_property_string(prop_str) {
             for (part, v) in map {
                 data[format_property(name, &part)] = v;
             }
diff --git a/src/rrd_graph_new.rs b/src/rrd_graph_new.rs
index 26a19b6..2d1db13 100644
--- a/src/rrd_graph_new.rs
+++ b/src/rrd_graph_new.rs
@@ -488,7 +488,7 @@ impl PwtRRDGraph {
                 &serie1_data[serie1_start..serie1_end],
             )
         } else {
-            (&time_data, &serie0_data, &serie1_data)
+            (time_data, serie0_data, serie1_data)
         }
     }
 
-- 
2.39.5



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


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

* [pdm-devel] [PATCH proxmox-yew-comp 02/15] remove needless casts
  2025-01-13 14:27 [pdm-devel] [PATCH proxmox-yew-comp 01/15] remove needless borrows Maximiliano Sandoval
@ 2025-01-13 14:27 ` Maximiliano Sandoval
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 03/15] apt_package_manager: use &str instead of format! Maximiliano Sandoval
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Maximiliano Sandoval @ 2025-01-13 14:27 UTC (permalink / raw)
  To: pdm-devel

Fixes:

warning: casting to the same type is unnecessary (`f64` -> `f64`)
   --> src/rrd_graph_new.rs:514:23
    |
514 |                     + (((t - start_time) as f64 * width) as f64) / time_span
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `((t - start_time) as f64 * width)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

warning: casting float literal to `f64` is unnecessary
   --> src/rrd_graph_new.rs:208:20
    |
208 |     while (range / (2.0 as f64).powi(l)) < 4.0 {
    |                    ^^^^^^^^^^^^ help: try: `2.0_f64`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 src/rrd_graph_new.rs | 10 +++++-----
 src/rrd_grid.rs      |  4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/rrd_graph_new.rs b/src/rrd_graph_new.rs
index 2d1db13..00fa39a 100644
--- a/src/rrd_graph_new.rs
+++ b/src/rrd_graph_new.rs
@@ -179,11 +179,11 @@ fn get_grid_unit_base10(min: f64, max: f64) -> f64 {
 
     let mut l = range.log10() as i32;
 
-    while (range / (10.0 as f64).powi(l)) < 2.0 {
+    while (range / 10.0_f64.powi(l)) < 2.0 {
         l -= 1;
     }
 
-    let mut res = (10.0 as f64).powi(l);
+    let mut res = 10.0_f64.powi(l);
 
     let count = range / res;
 
@@ -205,11 +205,11 @@ fn get_grid_unit_base2(min: f64, max: f64) -> f64 {
 
     let mut l = range.log2() as i32;
 
-    while (range / (2.0 as f64).powi(l)) < 4.0 {
+    while (range / 2.0_f64.powi(l)) < 4.0 {
         l -= 1;
     }
 
-    let mut res = (2.0 as f64).powi(l);
+    let mut res = 2.0_f64.powi(l);
 
     let count = range / res;
 
@@ -511,7 +511,7 @@ impl PwtRRDGraph {
             let width = (layout.width - layout.left_offset - layout.grid_border * 2) as f64;
             move |t: i64| -> f64 {
                 (layout.left_offset + layout.grid_border) as f64
-                    + (((t - start_time) as f64 * width) as f64) / time_span
+                    + ((t - start_time) as f64 * width) / time_span
             }
         };
 
diff --git a/src/rrd_grid.rs b/src/rrd_grid.rs
index 9ad3d7d..5432b72 100644
--- a/src/rrd_grid.rs
+++ b/src/rrd_grid.rs
@@ -45,11 +45,11 @@ impl Component for ProxmoxRRDGrid {
                 let cw = 800;
                 let width = width.max(cw);
                 let padding = 6;
-                let mut cols = (width / cw) as usize;
+                let mut cols = width / cw;
                 if cols == 0 {
                     cols = 1;
                 }
-                let col_width = (width as usize - 2 * padding) / cols;
+                let col_width = (width - 2 * padding) / cols;
                 self.cols = cols;
                 self.col_width = col_width - padding;
                 true
-- 
2.39.5



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


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

* [pdm-devel] [PATCH proxmox-yew-comp 03/15] apt_package_manager: use &str instead of format!
  2025-01-13 14:27 [pdm-devel] [PATCH proxmox-yew-comp 01/15] remove needless borrows Maximiliano Sandoval
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 02/15] remove needless casts Maximiliano Sandoval
@ 2025-01-13 14:27 ` Maximiliano Sandoval
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 04/15] apt_repositories: collapse else-if blocks Maximiliano Sandoval
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Maximiliano Sandoval @ 2025-01-13 14:27 UTC (permalink / raw)
  To: pdm-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 src/apt_package_manager.rs | 2 +-
 src/apt_repositories.rs    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/apt_package_manager.rs b/src/apt_package_manager.rs
index 5171d81..11d7eb8 100644
--- a/src/apt_package_manager.rs
+++ b/src/apt_package_manager.rs
@@ -85,7 +85,7 @@ fn tree_entry_ordering(a: &TreeEntry, b: &TreeEntry) -> Ordering {
 fn update_list_to_tree(updates: &[APTUpdateInfo]) -> SlabTree<TreeEntry> {
     let mut tree = SlabTree::new();
 
-    let mut root = tree.set_root(TreeEntry::Root(Key::from(format!("root"))));
+    let mut root = tree.set_root(TreeEntry::Root(Key::from("root")));
     root.set_expanded(true);
 
     let mut origin_map = HashMap::new();
diff --git a/src/apt_repositories.rs b/src/apt_repositories.rs
index bf308bd..534d642 100644
--- a/src/apt_repositories.rs
+++ b/src/apt_repositories.rs
@@ -326,7 +326,7 @@ impl ExtractPrimaryKey for TreeEntry {
 fn apt_configuration_to_tree(config: &APTRepositoriesResult) -> SlabTree<TreeEntry> {
     let mut tree = SlabTree::new();
 
-    let mut root = tree.set_root(TreeEntry::Root(Key::from(format!("root"))));
+    let mut root = tree.set_root(TreeEntry::Root(Key::from("root")));
     root.set_expanded(true);
 
     let mut info_map: HashMap<String, HashMap<usize, Vec<APTRepositoryInfo>>> = HashMap::new();
-- 
2.39.5



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


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

* [pdm-devel] [PATCH proxmox-yew-comp 04/15] apt_repositories: collapse else-if blocks
  2025-01-13 14:27 [pdm-devel] [PATCH proxmox-yew-comp 01/15] remove needless borrows Maximiliano Sandoval
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 02/15] remove needless casts Maximiliano Sandoval
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 03/15] apt_package_manager: use &str instead of format! Maximiliano Sandoval
@ 2025-01-13 14:27 ` Maximiliano Sandoval
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 05/15] apt_repositories: collapse match statement with if-let Maximiliano Sandoval
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Maximiliano Sandoval @ 2025-01-13 14:27 UTC (permalink / raw)
  To: pdm-devel

Fixes:

warning: this `else { if .. }` block can be collapsed
   --> src/apt_repositories.rs:151:12
    |
151 |       } else {
    |  ____________^
152 | |         if config.errors.is_empty() {
153 | |             // just avoid that we show "get updates"
154 | |             if has_test || has_no_subscription {
...   |
165 | |         }
166 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_else_if
    = note: `#[warn(clippy::collapsible_else_if)]` on by default
help: collapse nested if block
    |
151 ~     } else if config.errors.is_empty() {
152 +         // just avoid that we show "get updates"
153 +         if has_test || has_no_subscription {
154 +             list.push(StatusLine::ok(tr!(
155 +                 "You get updates for {0}",
156 +                 product.project_text()
157 +             )));
158 +         } else if has_enterprise && active_subscription {
159 +             list.push(StatusLine::ok(tr!(
160 +                 "You get supported updates for {0}",
161 +                 product.project_text()
162 +             )));
163 +         }
164 +     }
    |

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 src/apt_repositories.rs | 43 +++++++++++++++++++----------------------
 1 file changed, 20 insertions(+), 23 deletions(-)

diff --git a/src/apt_repositories.rs b/src/apt_repositories.rs
index 534d642..8e6207f 100644
--- a/src/apt_repositories.rs
+++ b/src/apt_repositories.rs
@@ -148,20 +148,18 @@ fn update_status_store(
             "No {0} repository is enabled, you do not get any updates!",
             product.project_text()
         )));
-    } else {
-        if config.errors.is_empty() {
-            // just avoid that we show "get updates"
-            if has_test || has_no_subscription {
-                list.push(StatusLine::ok(tr!(
-                    "You get updates for {0}",
-                    product.project_text()
-                )));
-            } else if has_enterprise && active_subscription {
-                list.push(StatusLine::ok(tr!(
-                    "You get supported updates for {0}",
-                    product.project_text()
-                )));
-            }
+    } else if config.errors.is_empty() {
+        // just avoid that we show "get updates"
+        if has_test || has_no_subscription {
+            list.push(StatusLine::ok(tr!(
+                "You get updates for {0}",
+                product.project_text()
+            )));
+        } else if has_enterprise && active_subscription {
+            list.push(StatusLine::ok(tr!(
+                "You get supported updates for {0}",
+                product.project_text()
+            )));
         }
     }
 
@@ -186,20 +184,19 @@ fn update_status_store(
             ignore_pre_upgrade_warning.insert((&info.path, info.index));
             check_mixed_suites = true;
         }
-        if info.kind == "origin" {
-            if info.message == "Debian" || info.message == "Proxmox" {
-                controlled_origin.insert((&info.path, info.index));
-            }
+        if info.kind == "origin" && (info.message == "Debian" || info.message == "Proxmox") {
+            controlled_origin.insert((&info.path, info.index));
         }
     }
 
     let mut suites_warning = false;
     for info in &config.infos {
-        if info.kind == "warning" && info.property.as_deref() == Some("Suites") {
-            if enabled_repos.contains(&(&info.path, info.index)) {
-                suites_warning = true;
-                break;
-            }
+        if info.kind == "warning"
+            && info.property.as_deref() == Some("Suites")
+            && enabled_repos.contains(&(&info.path, info.index))
+        {
+            suites_warning = true;
+            break;
         }
     }
 
-- 
2.39.5



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


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

* [pdm-devel] [PATCH proxmox-yew-comp 05/15] apt_repositories: collapse match statement with if-let
  2025-01-13 14:27 [pdm-devel] [PATCH proxmox-yew-comp 01/15] remove needless borrows Maximiliano Sandoval
                   ` (2 preceding siblings ...)
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 04/15] apt_repositories: collapse else-if blocks Maximiliano Sandoval
@ 2025-01-13 14:27 ` Maximiliano Sandoval
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 06/15] use any() instead of find and is_none combination Maximiliano Sandoval
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Maximiliano Sandoval @ 2025-01-13 14:27 UTC (permalink / raw)
  To: pdm-devel

Fixes:

warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> src/apt_repositories.rs:521:17
    |
521 | /                 match selected_record {
522 | |                     TreeEntry::Repository {
523 | |                         path, index, repo, ..
524 | |                     } => {
...   |
544 | |                     _ => {}
545 | |                 }
    | |_________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
    = note: `#[warn(clippy::single_match)]` on by default
help: try
    |
521 ~                 if let TreeEntry::Repository {
522 +                         path, index, repo, ..
523 +                     } = selected_record {
524 +                     let param = json!({
525 +                         "path": path,
526 +                         "index": index,
527 +                         "enabled": !repo.enabled,
528 +                     });
529 +                     // fixme: add digest to protect against concurrent changes
530 +                     let url = format!("{}/repositories", props.base_url);
531 +                     let link = ctx.link();
532 +                     link.clone().spawn(async move {
533 +                         match crate::http_post(url, Some(param)).await {
534 +                             Ok(()) => {
535 +                                 link.send_reload();
536 +                             }
537 +                             Err(err) => {
538 +                                 link.show_error(tr!("API call failed"), err, true);
539 +                             }
540 +                         }
541 +                     });
542 +                 }

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 src/apt_repositories.rs | 44 ++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 23 deletions(-)

diff --git a/src/apt_repositories.rs b/src/apt_repositories.rs
index 8e6207f..365e01b 100644
--- a/src/apt_repositories.rs
+++ b/src/apt_repositories.rs
@@ -515,30 +515,28 @@ impl LoadableComponent for ProxmoxAptRepositories {
                     Some(record) => record,
                     None => return false,
                 };
-                match selected_record {
-                    TreeEntry::Repository {
-                        path, index, repo, ..
-                    } => {
-                        let param = json!({
-                            "path": path,
-                            "index": index,
-                            "enabled": !repo.enabled,
-                        });
-                        // fixme: add digest to protect against concurrent changes
-                        let url = format!("{}/repositories", props.base_url);
-                        let link = ctx.link();
-                        link.clone().spawn(async move {
-                            match crate::http_post(url, Some(param)).await {
-                                Ok(()) => {
-                                    link.send_reload();
-                                }
-                                Err(err) => {
-                                    link.show_error(tr!("API call failed"), err, true);
-                                }
+                if let TreeEntry::Repository {
+                    path, index, repo, ..
+                } = selected_record
+                {
+                    let param = json!({
+                        "path": path,
+                        "index": index,
+                        "enabled": !repo.enabled,
+                    });
+                    // fixme: add digest to protect against concurrent changes
+                    let url = format!("{}/repositories", props.base_url);
+                    let link = ctx.link();
+                    link.clone().spawn(async move {
+                        match crate::http_post(url, Some(param)).await {
+                            Ok(()) => {
+                                link.send_reload();
                             }
-                        });
-                    }
-                    _ => {}
+                            Err(err) => {
+                                link.show_error(tr!("API call failed"), err, true);
+                            }
+                        }
+                    });
                 }
                 false
             }
-- 
2.39.5



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


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

* [pdm-devel] [PATCH proxmox-yew-comp 06/15] use any() instead of find and is_none combination
  2025-01-13 14:27 [pdm-devel] [PATCH proxmox-yew-comp 01/15] remove needless borrows Maximiliano Sandoval
                   ` (3 preceding siblings ...)
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 05/15] apt_repositories: collapse match statement with if-let Maximiliano Sandoval
@ 2025-01-13 14:27 ` Maximiliano Sandoval
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 07/15] remove unnecesary closure used with then() Maximiliano Sandoval
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Maximiliano Sandoval @ 2025-01-13 14:27 UTC (permalink / raw)
  To: pdm-devel

Fixes:

warning: called `is_none()` after searching an `Iterator` with `find`
   --> src/apt_repositories.rs:282:8
    |
282 |     if list.iter().find(|l| l.status != Status::Ok).is_none() {
    |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!list.iter().any(|l| l.status != Status::Ok)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some
    = note: `#[warn(clippy::search_is_some)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 src/apt_repositories.rs           | 2 +-
 src/configuration/network_view.rs | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/apt_repositories.rs b/src/apt_repositories.rs
index 365e01b..2998a5a 100644
--- a/src/apt_repositories.rs
+++ b/src/apt_repositories.rs
@@ -276,7 +276,7 @@ fn update_status_store(
         )));
     }
 
-    if list.iter().find(|l| l.status != Status::Ok).is_none() {
+    if !list.iter().any(|l| l.status != Status::Ok) {
         list.push(StatusLine::ok(tr!(
             "All OK, you have production-ready repositories configured!"
         )));
diff --git a/src/configuration/network_view.rs b/src/configuration/network_view.rs
index c56d97c..4666b64 100644
--- a/src/configuration/network_view.rs
+++ b/src/configuration/network_view.rs
@@ -97,7 +97,7 @@ impl ProxmoxNetworkView {
 fn find_next_free_interface_id(prefix: &str, list: &[Interface]) -> Option<String> {
     for next in 0..9999 {
         let id = format!("{prefix}{next}");
-        if list.iter().find(|item| item.name == id).is_none() {
+        if !list.iter().any(|item| item.name == id) {
             return Some(id);
         }
     }
-- 
2.39.5



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


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

* [pdm-devel] [PATCH proxmox-yew-comp 07/15] remove unnecesary closure used with then()
  2025-01-13 14:27 [pdm-devel] [PATCH proxmox-yew-comp 01/15] remove needless borrows Maximiliano Sandoval
                   ` (4 preceding siblings ...)
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 06/15] use any() instead of find and is_none combination Maximiliano Sandoval
@ 2025-01-13 14:27 ` Maximiliano Sandoval
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 08/15] use *= operator for assigments Maximiliano Sandoval
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Maximiliano Sandoval @ 2025-01-13 14:27 UTC (permalink / raw)
  To: pdm-devel

Fixes:

warning: unnecessary closure used with `bool::then`
   --> src/rrd_graph_new.rs:950:33
    |
950 |         .attribute("data-show", (self.draw_cross && data_time.is_some()).then(|| ""))
    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
    = note: `#[warn(clippy::unnecessary_lazy_evaluations)]` on by default
help: use `then_some` instead
    |
950 |         .attribute("data-show", (self.draw_cross && data_time.is_some()).then_some(""))
    |                                                                          ~~~~~~~~~~~~~

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 src/rrd_graph_new.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/rrd_graph_new.rs b/src/rrd_graph_new.rs
index 00fa39a..426dc61 100644
--- a/src/rrd_graph_new.rs
+++ b/src/rrd_graph_new.rs
@@ -947,7 +947,7 @@ impl Component for PwtRRDGraph {
             .node_ref(self.tooltip_ref.clone())
         .attribute("role", "tooltip")
         .attribute("aria-live", "polite")
-        .attribute("data-show", (self.draw_cross && data_time.is_some()).then(|| ""))
+        .attribute("data-show", (self.draw_cross && data_time.is_some()).then_some(""))
         .class("pwt-tooltip")
         .class("pwt-tooltip-rich")
         .with_optional_child(match (self.serie0_visible, &props.serie0) {
@@ -981,7 +981,7 @@ impl Component for PwtRRDGraph {
                     "pwt-rrd-legend-marker0",
                     "fa",
                     "fa-circle",
-                    (!self.serie0_visible).then(|| "disabled")
+                    (!self.serie0_visible).then_some("disabled")
                 );
                 panel.add_tool(
                     Button::new(serie0.label.clone())
@@ -993,7 +993,7 @@ impl Component for PwtRRDGraph {
                     "pwt-rrd-legend-marker1",
                     "fa",
                     "fa-circle",
-                    (!self.serie1_visible).then(|| "disabled")
+                    (!self.serie1_visible).then_some("disabled")
                 );
                 panel.add_tool(
                     Button::new(serie1.label.clone())
-- 
2.39.5



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


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

* [pdm-devel] [PATCH proxmox-yew-comp 08/15] use *= operator for assigments
  2025-01-13 14:27 [pdm-devel] [PATCH proxmox-yew-comp 01/15] remove needless borrows Maximiliano Sandoval
                   ` (5 preceding siblings ...)
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 07/15] remove unnecesary closure used with then() Maximiliano Sandoval
@ 2025-01-13 14:27 ` Maximiliano Sandoval
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 09/15] use or_default and unwrap_or_default Maximiliano Sandoval
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Maximiliano Sandoval @ 2025-01-13 14:27 UTC (permalink / raw)
  To: pdm-devel

Fixes:

warning: manual implementation of an assign operation
   --> src/rrd_graph_new.rs:261:9
    |
261 |         l = l * 2;
    |         ^^^^^^^^^ help: replace it with: `l *= 2`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assign_op_pattern

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 src/rrd_graph_new.rs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/rrd_graph_new.rs b/src/rrd_graph_new.rs
index 426dc61..0b08e08 100644
--- a/src/rrd_graph_new.rs
+++ b/src/rrd_graph_new.rs
@@ -188,9 +188,9 @@ fn get_grid_unit_base10(min: f64, max: f64) -> f64 {
     let count = range / res;
 
     if count > 15.0 {
-        res = res * 5.0;
+        res *= 5.0;
     } else if count > 10.0 {
-        res = res * 2.0;
+        res *= 2.0;
     }
 
     res
@@ -214,7 +214,7 @@ fn get_grid_unit_base2(min: f64, max: f64) -> f64 {
     let count = range / res;
 
     if count > 15.0 {
-        res = res * 2.0;
+        res *= 2.0;
     }
 
     res
@@ -258,7 +258,7 @@ fn get_time_grid_unit(min: i64, max: i64) -> i64 {
     }
 
     while (l >= *units.first().unwrap()) && (range / l) > 10 {
-        l = l * 2;
+        l *= 2;
     }
 
     //log::info!("TIMERANG {l}");
-- 
2.39.5



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


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

* [pdm-devel] [PATCH proxmox-yew-comp 09/15] use or_default and unwrap_or_default
  2025-01-13 14:27 [pdm-devel] [PATCH proxmox-yew-comp 01/15] remove needless borrows Maximiliano Sandoval
                   ` (6 preceding siblings ...)
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 08/15] use *= operator for assigments Maximiliano Sandoval
@ 2025-01-13 14:27 ` Maximiliano Sandoval
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 10/15] remove redundant pattern matching Maximiliano Sandoval
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Maximiliano Sandoval @ 2025-01-13 14:27 UTC (permalink / raw)
  To: pdm-devel

Fixes:

warning: use of `or_insert` to construct default value
   --> src/apt_repositories.rs:335:55
    |
335 |         let inner = info_map.entry(info.path.clone()).or_insert(HashMap::new());
    |                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `or_default()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_default
    = note: `#[warn(clippy::unwrap_or_default)]` on by default

warning: use of `or_insert` to construct default value
   --> src/apt_repositories.rs:336:45
    |
336 |         let entry = inner.entry(info.index).or_insert(Vec::new());
    |                                             ^^^^^^^^^^^^^^^^^^^^^ help: try: `or_default()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 src/apt_repositories.rs           | 4 ++--
 src/configuration/network_edit.rs | 2 +-
 src/configuration/network_view.rs | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/apt_repositories.rs b/src/apt_repositories.rs
index 2998a5a..7149545 100644
--- a/src/apt_repositories.rs
+++ b/src/apt_repositories.rs
@@ -329,8 +329,8 @@ fn apt_configuration_to_tree(config: &APTRepositoriesResult) -> SlabTree<TreeEnt
     let mut info_map: HashMap<String, HashMap<usize, Vec<APTRepositoryInfo>>> = HashMap::new();
 
     for info in &config.infos {
-        let inner = info_map.entry(info.path.clone()).or_insert(HashMap::new());
-        let entry = inner.entry(info.index).or_insert(Vec::new());
+        let inner = info_map.entry(info.path.clone()).or_default();
+        let entry = inner.entry(info.index).or_default();
         entry.push(info.clone());
     }
 
diff --git a/src/configuration/network_edit.rs b/src/configuration/network_edit.rs
index 010dc30..cf1bc60 100644
--- a/src/configuration/network_edit.rs
+++ b/src/configuration/network_edit.rs
@@ -184,7 +184,7 @@ fn render_bond_form(form_ctx: FormContext, props: &NetworkEdit) -> Html {
         .get_field_value("bond_mode")
         .map(|v| v.as_str().map(String::from))
         .flatten()
-        .unwrap_or(String::new());
+        .unwrap_or_default();
 
     let allow_xmit_hash_policy = mode == "balance-xor" || mode == "802.3ad";
 
diff --git a/src/configuration/network_view.rs b/src/configuration/network_view.rs
index 4666b64..5dd0acf 100644
--- a/src/configuration/network_view.rs
+++ b/src/configuration/network_view.rs
@@ -333,12 +333,12 @@ fn format_ports_slaves(interface: &Interface) -> String {
             .bridge_ports
             .as_ref()
             .map(|ports| ports.join(" "))
-            .unwrap_or(String::new()),
+            .unwrap_or_default(),
         NetworkInterfaceType::Bond => interface
             .slaves
             .as_ref()
             .map(|ports| ports.join(" "))
-            .unwrap_or(String::new()),
+            .unwrap_or_default(),
         NetworkInterfaceType::Alias
         | NetworkInterfaceType::Vlan
         | NetworkInterfaceType::Eth
@@ -500,7 +500,7 @@ fn columns() -> Rc<Vec<DataTableHeader<Interface>>> {
         DataTableColumn::new("Comment")
             .flex(1)
             .render(|item: &Interface| html!{
-                item.comments.clone().unwrap_or(String::new())
+                item.comments.clone().unwrap_or_default()
             })
             .into()
 
-- 
2.39.5



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


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

* [pdm-devel] [PATCH proxmox-yew-comp 10/15] remove redundant pattern matching
  2025-01-13 14:27 [pdm-devel] [PATCH proxmox-yew-comp 01/15] remove needless borrows Maximiliano Sandoval
                   ` (7 preceding siblings ...)
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 09/15] use or_default and unwrap_or_default Maximiliano Sandoval
@ 2025-01-13 14:27 ` Maximiliano Sandoval
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 11/15] use std::mem::swap instead of manual swapping Maximiliano Sandoval
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Maximiliano Sandoval @ 2025-01-13 14:27 UTC (permalink / raw)
  To: pdm-devel

Fixes:

warning: redundant pattern matching, consider using `is_err()`
   --> src/rrd_timeframe_selector.rs:116:20
    |
116 |             if let Err(_) = store.set_item("ProxmoxRRDTimeframe", &timeframe_str) {
    |             -------^^^^^^-------------------------------------------------------- help: try: `if store.set_item("ProxmoxRRDTimeframe", &timeframe_str).is_err()`
    |
    = note: this will change drop order of the result, as well as all temporaries
    = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching
    = note: `#[warn(clippy::redundant_pattern_matching)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 src/rrd_timeframe_selector.rs | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/rrd_timeframe_selector.rs b/src/rrd_timeframe_selector.rs
index 00f22ab..a027046 100644
--- a/src/rrd_timeframe_selector.rs
+++ b/src/rrd_timeframe_selector.rs
@@ -113,7 +113,10 @@ impl RRDTimeframe {
     pub fn store(&self) {
         if let Some(store) = local_storage() {
             let timeframe_str = self.serialize();
-            if let Err(_) = store.set_item("ProxmoxRRDTimeframe", &timeframe_str) {
+            if store
+                .set_item("ProxmoxRRDTimeframe", &timeframe_str)
+                .is_err()
+            {
                 log::error!("RRDTimeframe::store - set_item failed");
             } else {
                 emit_rrd_timeframe_changed_event();
-- 
2.39.5



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


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

* [pdm-devel] [PATCH proxmox-yew-comp 11/15] use std::mem::swap instead of manual swapping
  2025-01-13 14:27 [pdm-devel] [PATCH proxmox-yew-comp 01/15] remove needless borrows Maximiliano Sandoval
                   ` (8 preceding siblings ...)
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 10/15] remove redundant pattern matching Maximiliano Sandoval
@ 2025-01-13 14:27 ` Maximiliano Sandoval
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 12/15] use enumerate() instead of indexing Maximiliano Sandoval
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Maximiliano Sandoval @ 2025-01-13 14:27 UTC (permalink / raw)
  To: pdm-devel

Fixes:

warning: this looks like you are swapping `start_x` and `end_x` manually
   --> src/rrd_graph_new.rs:643:25
    |
643 | /                         let t = start_x;
644 | |                         start_x = end_x;
645 | |                         end_x = t;
    | |__________________________________^ help: try: `std::mem::swap(&mut start_x, &mut end_x);`
    |
    = note: or maybe you should use `std::mem::replace`?
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_swap
    = note: `#[warn(clippy::manual_swap)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 src/rrd_graph_new.rs | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/rrd_graph_new.rs b/src/rrd_graph_new.rs
index 0b08e08..32b6126 100644
--- a/src/rrd_graph_new.rs
+++ b/src/rrd_graph_new.rs
@@ -640,9 +640,7 @@ impl PwtRRDGraph {
                     let mut end_x = compute_x(*end_data);
 
                     if start_x > end_x {
-                        let t = start_x;
-                        start_x = end_x;
-                        end_x = t;
+                        std::mem::swap(&mut start_x, &mut end_x);
                     }
 
                     let start_y = compute_y(min_data);
-- 
2.39.5



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


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

* [pdm-devel] [PATCH proxmox-yew-comp 12/15] use enumerate() instead of indexing
  2025-01-13 14:27 [pdm-devel] [PATCH proxmox-yew-comp 01/15] remove needless borrows Maximiliano Sandoval
                   ` (9 preceding siblings ...)
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 11/15] use std::mem::swap instead of manual swapping Maximiliano Sandoval
@ 2025-01-13 14:27 ` Maximiliano Sandoval
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 13/15] use len() instead of length comparison to zero Maximiliano Sandoval
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Maximiliano Sandoval @ 2025-01-13 14:27 UTC (permalink / raw)
  To: pdm-devel

Fixes:

warning: the loop variable `i` is used to index `time_data`
   --> src/rrd_graph_new.rs:388:14
    |
388 |     for i in 0..time_data.len() {
    |              ^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_range_loop
    = note: `#[warn(clippy::needless_range_loop)]` on by default
help: consider using an iterator and enumerate()
    |
388 |     for (i, <item>) in time_data.iter().enumerate() {
    |         ~~~~~~~~~~~    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 src/rrd_graph_new.rs | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/rrd_graph_new.rs b/src/rrd_graph_new.rs
index 32b6126..f549c4f 100644
--- a/src/rrd_graph_new.rs
+++ b/src/rrd_graph_new.rs
@@ -385,10 +385,9 @@ fn compute_outline_path(
 ) -> String {
     let mut path = String::new();
     let mut last_undefined = true;
-    for i in 0..time_data.len() {
-        let t = time_data[i];
+    for (i, t) in time_data.iter().enumerate() {
         let value = *values.get(i).unwrap_or(&f64::NAN);
-        let x = compute_x(t);
+        let x = compute_x(*t);
 
         if last_undefined {
             if value.is_nan() {
-- 
2.39.5



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


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

* [pdm-devel] [PATCH proxmox-yew-comp 13/15] use len() instead of length comparison to zero
  2025-01-13 14:27 [pdm-devel] [PATCH proxmox-yew-comp 01/15] remove needless borrows Maximiliano Sandoval
                   ` (10 preceding siblings ...)
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 12/15] use enumerate() instead of indexing Maximiliano Sandoval
@ 2025-01-13 14:27 ` Maximiliano Sandoval
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 14/15] use cloned() instead of explicit clone() in closure Maximiliano Sandoval
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Maximiliano Sandoval @ 2025-01-13 14:27 UTC (permalink / raw)
  To: pdm-devel

Fixes:

warning: length comparison to zero
   --> src/rrd_graph_new.rs:660:22
    |
660 |                 _ if data0.len() == 0 => {}
    |                      ^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `data0.is_empty()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
    = note: `#[warn(clippy::len_zero)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 src/rrd_graph_new.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/rrd_graph_new.rs b/src/rrd_graph_new.rs
index f549c4f..21890a1 100644
--- a/src/rrd_graph_new.rs
+++ b/src/rrd_graph_new.rs
@@ -654,7 +654,7 @@ impl PwtRRDGraph {
                             .into(),
                     );
                 }
-                _ if data0.len() == 0 => {}
+                _ if data0.is_empty() => {}
                 _ => log::debug!("out of bound selection start {start}, end {end} for {data0:?}"),
             }
         }
-- 
2.39.5



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


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

* [pdm-devel] [PATCH proxmox-yew-comp 14/15] use cloned() instead of explicit clone() in closure
  2025-01-13 14:27 [pdm-devel] [PATCH proxmox-yew-comp 01/15] remove needless borrows Maximiliano Sandoval
                   ` (11 preceding siblings ...)
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 13/15] use len() instead of length comparison to zero Maximiliano Sandoval
@ 2025-01-13 14:27 ` Maximiliano Sandoval
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 15/15] use and_then instead of map(..).flatten(..) on Option Maximiliano Sandoval
  2025-01-14  8:29 ` [pdm-devel] applied: [PATCH proxmox-yew-comp 01/15] remove needless borrows Dietmar Maurer
  14 siblings, 0 replies; 16+ messages in thread
From: Maximiliano Sandoval @ 2025-01-13 14:27 UTC (permalink / raw)
  To: pdm-devel

Fixes:

warning: you are using an explicit closure for cloning elements
  --> src/configuration/network_view.rs:91:31
   |
91 |             selected_record = self.store.read().lookup_record(key).map(|r| r.clone());
   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `self.store.read().lookup_record(key).cloned()`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_clone
   = note: `#[warn(clippy::map_clone)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 src/configuration/network_view.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/configuration/network_view.rs b/src/configuration/network_view.rs
index 5dd0acf..20ad5d0 100644
--- a/src/configuration/network_view.rs
+++ b/src/configuration/network_view.rs
@@ -88,7 +88,7 @@ impl ProxmoxNetworkView {
         let selected_key = self.selection.selected_key();
         let mut selected_record = None;
         if let Some(key) = &selected_key {
-            selected_record = self.store.read().lookup_record(key).map(|r| r.clone());
+            selected_record = self.store.read().lookup_record(key).cloned();
         }
         selected_record
     }
-- 
2.39.5



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


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

* [pdm-devel] [PATCH proxmox-yew-comp 15/15] use and_then instead of map(..).flatten(..) on Option
  2025-01-13 14:27 [pdm-devel] [PATCH proxmox-yew-comp 01/15] remove needless borrows Maximiliano Sandoval
                   ` (12 preceding siblings ...)
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 14/15] use cloned() instead of explicit clone() in closure Maximiliano Sandoval
@ 2025-01-13 14:27 ` Maximiliano Sandoval
  2025-01-14  8:29 ` [pdm-devel] applied: [PATCH proxmox-yew-comp 01/15] remove needless borrows Dietmar Maurer
  14 siblings, 0 replies; 16+ messages in thread
From: Maximiliano Sandoval @ 2025-01-13 14:27 UTC (permalink / raw)
  To: pdm-devel

Fixes:

warning: called `map(..).flatten()` on `Option`
  --> src/configuration/network_view.rs:30:10
   |
30 |           .map(|c| c.as_str())
   |  __________^
31 | |         .flatten()
   | |__________________^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|c| c.as_str())`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_flatten
   = note: `#[warn(clippy::map_flatten)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 src/configuration/network_edit.rs | 3 +--
 src/configuration/network_view.rs | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/configuration/network_edit.rs b/src/configuration/network_edit.rs
index cf1bc60..84a9380 100644
--- a/src/configuration/network_edit.rs
+++ b/src/configuration/network_edit.rs
@@ -182,8 +182,7 @@ fn render_bond_form(form_ctx: FormContext, props: &NetworkEdit) -> Html {
     let mode = form_ctx
         .read()
         .get_field_value("bond_mode")
-        .map(|v| v.as_str().map(String::from))
-        .flatten()
+        .and_then(|v| v.as_str().map(String::from))
         .unwrap_or_default();
 
     let allow_xmit_hash_policy = mode == "balance-xor" || mode == "802.3ad";
diff --git a/src/configuration/network_view.rs b/src/configuration/network_view.rs
index 20ad5d0..cc2faae 100644
--- a/src/configuration/network_view.rs
+++ b/src/configuration/network_view.rs
@@ -27,8 +27,7 @@ async fn load_interfaces() -> Result<(Vec<Interface>, String), Error> {
     let changes = resp
         .attribs
         .get("changes")
-        .map(|c| c.as_str())
-        .flatten()
+        .and_then(|c| c.as_str())
         .unwrap_or("");
     Ok((data, changes.to_string()))
 }
-- 
2.39.5



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


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

* [pdm-devel] applied: [PATCH proxmox-yew-comp 01/15] remove needless borrows
  2025-01-13 14:27 [pdm-devel] [PATCH proxmox-yew-comp 01/15] remove needless borrows Maximiliano Sandoval
                   ` (13 preceding siblings ...)
  2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 15/15] use and_then instead of map(..).flatten(..) on Option Maximiliano Sandoval
@ 2025-01-14  8:29 ` Dietmar Maurer
  14 siblings, 0 replies; 16+ messages in thread
From: Dietmar Maurer @ 2025-01-14  8:29 UTC (permalink / raw)
  To: Proxmox Datacenter Manager development discussion, Maximiliano Sandoval

applied all 15 patches

(fixed commit message of patch 13)

- use len() instead of length comparison to zero
+ use is_empty() instead of length comparison to zero


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


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

end of thread, other threads:[~2025-01-14  8:30 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-13 14:27 [pdm-devel] [PATCH proxmox-yew-comp 01/15] remove needless borrows Maximiliano Sandoval
2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 02/15] remove needless casts Maximiliano Sandoval
2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 03/15] apt_package_manager: use &str instead of format! Maximiliano Sandoval
2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 04/15] apt_repositories: collapse else-if blocks Maximiliano Sandoval
2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 05/15] apt_repositories: collapse match statement with if-let Maximiliano Sandoval
2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 06/15] use any() instead of find and is_none combination Maximiliano Sandoval
2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 07/15] remove unnecesary closure used with then() Maximiliano Sandoval
2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 08/15] use *= operator for assigments Maximiliano Sandoval
2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 09/15] use or_default and unwrap_or_default Maximiliano Sandoval
2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 10/15] remove redundant pattern matching Maximiliano Sandoval
2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 11/15] use std::mem::swap instead of manual swapping Maximiliano Sandoval
2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 12/15] use enumerate() instead of indexing Maximiliano Sandoval
2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 13/15] use len() instead of length comparison to zero Maximiliano Sandoval
2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 14/15] use cloned() instead of explicit clone() in closure Maximiliano Sandoval
2025-01-13 14:27 ` [pdm-devel] [PATCH proxmox-yew-comp 15/15] use and_then instead of map(..).flatten(..) on Option Maximiliano Sandoval
2025-01-14  8:29 ` [pdm-devel] applied: [PATCH proxmox-yew-comp 01/15] remove needless borrows Dietmar Maurer

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