[pbs-devel] [PATCH proxmox 4/8] apt: cache_api: simplify match with unwrap_or_default

Maximiliano Sandoval m.sandoval at proxmox.com
Mon Aug 26 14:15:32 CEST 2024


Fixes:

warning: match can be simplified with `.unwrap_or_default()`
  --> proxmox-apt/src/cache_api.rs:77:28
   |
77 |           let mut notified = match cache.notified {
   |  ____________________________^
78 | |             Some(notified) => notified,
79 | |             None => std::collections::HashMap::new(),
80 | |         };
   | |_________^ help: replace it with: `cache.notified.unwrap_or_default()`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or_default
   = note: `#[warn(clippy::manual_unwrap_or_default)]` on by default

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

diff --git a/proxmox-apt/src/cache_api.rs b/proxmox-apt/src/cache_api.rs
index 979f47ed..a2cd67f8 100644
--- a/proxmox-apt/src/cache_api.rs
+++ b/proxmox-apt/src/cache_api.rs
@@ -74,10 +74,7 @@ pub fn update_database<P: AsRef<Path>>(
     let mut cache = crate::cache::update_cache(apt_state_file)?;
 
     if notify {
-        let mut notified = match cache.notified {
-            Some(notified) => notified,
-            None => std::collections::HashMap::new(),
-        };
+        let mut notified = cache.notified.unwrap_or_default();
         let mut to_notify: Vec<&APTUpdateInfo> = Vec::new();
 
         for pkg in &cache.package_status {
-- 
2.39.2





More information about the pbs-devel mailing list