[pdm-devel] [PATCH proxmox-yew-comp 15/15] use and_then instead of map(..).flatten(..) on Option
Maximiliano Sandoval
m.sandoval at proxmox.com
Mon Jan 13 15:27:25 CET 2025
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 at 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
More information about the pdm-devel
mailing list