public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH backup 2/2] restore-daemon: Use first() when it makes sense
Date: Wed, 14 Feb 2024 10:04:48 +0100	[thread overview]
Message-ID: <20240214090448.123884-3-m.sandoval@proxmox.com> (raw)
In-Reply-To: <20240214090448.123884-1-m.sandoval@proxmox.com>

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@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





      parent reply	other threads:[~2024-02-14  9:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14  9:04 [pbs-devel] [PATCH backup 0/2] More clippy fixes Maximiliano Sandoval
2024-02-14  9:04 ` [pbs-devel] [PATCH backup 1/2] restore-daemon: Module docs should use //! rather than ///! Maximiliano Sandoval
2024-02-14  9:04 ` Maximiliano Sandoval [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240214090448.123884-3-m.sandoval@proxmox.com \
    --to=m.sandoval@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal