[pbs-devel] [PATCH proxmox 01/10] apt: file: Use unwrap_or_default instead of match

Maximiliano Sandoval m.sandoval at proxmox.com
Tue Dec 3 11:20:29 CET 2024


Fixes the manual_unwrap_or_default clippy lint:

```
warning: match can be simplified with `.unwrap_or_default()`
   --> proxmox-apt/src/repositories/file.rs:369:30
    |
369 |               let mut origin = match repo.get_cached_origin(apt_lists_dir) {
    |  ______________________________^
370 | |                 Ok(option) => option,
371 | |                 Err(_) => None,
372 | |             };
    | |_____________^ help: replace it with: `repo.get_cached_origin(apt_lists_dir).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/repositories/file.rs | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/proxmox-apt/src/repositories/file.rs b/proxmox-apt/src/repositories/file.rs
index f176ab71..e34e84e0 100644
--- a/proxmox-apt/src/repositories/file.rs
+++ b/proxmox-apt/src/repositories/file.rs
@@ -366,10 +366,7 @@ impl APTRepositoryFileImpl for APTRepositoryFile {
         };
 
         for (n, repo) in self.repositories.iter().enumerate() {
-            let mut origin = match repo.get_cached_origin(apt_lists_dir) {
-                Ok(option) => option,
-                Err(_) => None,
-            };
+            let mut origin = repo.get_cached_origin(apt_lists_dir).unwrap_or_default();
 
             if origin.is_none() {
                 origin = repo.origin_from_uris();
-- 
2.39.5





More information about the pbs-devel mailing list