[pbs-devel] [PATCH backup 2/2] restore-daemon: Use first() when it makes sense

Maximiliano Sandoval m.sandoval at proxmox.com
Wed Feb 14 10:04:48 CET 2024


Fixes the following Clippy lint

```
warning: accessing first element with `comp.get(0)`
   --> proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs:102:37
    |
102 |                 if let Some(comp) = comp.get(0) {
    |                                     ^^^^^^^^^^^ help: try: `comp.first()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
    = note: `#[warn(clippy::get_first)]` on by default
```

The lint

```
warning: accessing first element with `comp.get(0)`
   --> proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs:117:56
    |
117 |                 if let (Some(ref vg), Some(ref lv)) = (comp.get(0), comp.get(1)) {
    |                                                        ^^^^^^^^^^^ help: try: `comp.first()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
```

was not fixed (nor a clippy::allow was added) on purpose.

Signed-off-by: Maximiliano Sandoval <m.sandoval at proxmox.com>
---
 proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
index bde459dd..f651afea 100644
--- a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
+++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
@@ -99,7 +99,7 @@ impl Bucket {
         let ty = ty.as_ref();
         haystack.iter_mut().find(|b| match b {
             Bucket::Partition(data) => {
-                if let Some(comp) = comp.get(0) {
+                if let Some(comp) = comp.first() {
                     ty == "part" && comp.as_ref().parse::<i32>().unwrap() == data.number
                 } else {
                     false
@@ -107,7 +107,7 @@ impl Bucket {
             }
             Bucket::RawFs(_) => ty == "raw",
             Bucket::ZPool(data) => {
-                if let Some(ref comp) = comp.get(0) {
+                if let Some(ref comp) = comp.first() {
                     ty == "zpool" && comp.as_ref() == data.name
                 } else {
                     false
-- 
2.39.2





More information about the pbs-devel mailing list