]> git.proxmox.com Git - ui/proxmox-yew-widget-toolkit.git/commitdiff
theme: use `is_err` instead of `if let Err(_)`
authorShannon Sterz <s.sterz@proxmox.com>
Fri, 3 Jan 2025 13:19:12 +0000 (14:19 +0100)
committerShannon Sterz <s.sterz@proxmox.com>
Fri, 3 Jan 2025 15:46:35 +0000 (16:46 +0100)
this is more idiomatic and removes the clippy lint
`redundant_pattern_matching` [1].

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

src/state/theme.rs

index d88737ad3bd48d349f85faca0edfc1f063ebab55..0b6b65f0004474f6639d0bbeca346fd24cbee584 100644 (file)
@@ -192,7 +192,7 @@ impl Theme {
     /// Store the theme mode and emit the `pwt-theme-changed` event.
     pub fn store_theme_mode(mode: ThemeMode) -> Result<(), Error> {
         if let Some(store) = local_storage() {
-            if let Err(_) = store.set_item("ThemeMode", &mode.to_string()) {
+            if store.set_item("ThemeMode", &mode.to_string()).is_err() {
                 bail!("store_them_mode: set_item failed");
             }
         } else {
@@ -207,7 +207,10 @@ impl Theme {
     /// Store the theme density and emit the `pwt-theme-changed` event.
     pub fn store_theme_density(density: ThemeDensity) -> Result<(), Error> {
         if let Some(store) = local_storage() {
-            if let Err(_) = store.set_item("ThemeDensity", &density.to_string()) {
+            if store
+                .set_item("ThemeDensity", &density.to_string())
+                .is_err()
+            {
                 bail!("store_theme_density: set_item failed");
             }
         } else {
@@ -222,7 +225,7 @@ impl Theme {
     /// Store the theme name and emit the `pwt-theme-changed` event.
     pub fn store_theme_name(name: &str) -> Result<(), Error> {
         if let Some(store) = local_storage() {
-            if let Err(_) = store.set_item("ThemeName", name) {
+            if store.set_item("ThemeName", name).is_err() {
                 bail!("store_theme_name: set_item failed");
             }
         } else {