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 06/13] access first element with first() rather than get(0)
Date: Mon, 12 Feb 2024 14:17:31 +0100	[thread overview]
Message-ID: <20240212131734.454966-6-m.sandoval@proxmox.com> (raw)
In-Reply-To: <20240212131734.454966-1-m.sandoval@proxmox.com>

Fixes the clippy lint

```
warning: accessing first element with `self.transports.get(0)`
   --> pbs-tape/src/lib.rs:283:9
    |
283 | /         self.transports
284 | |             .get(0)
    | |___________________^ help: try: `self.transports.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
```

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 pbs-tape/src/lib.rs           | 2 +-
 pbs-tape/src/sg_pt_changer.rs | 2 +-
 src/server/realm_sync_job.rs  | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/pbs-tape/src/lib.rs b/pbs-tape/src/lib.rs
index 1de2bc54..8d408b70 100644
--- a/pbs-tape/src/lib.rs
+++ b/pbs-tape/src/lib.rs
@@ -281,7 +281,7 @@ impl MtxStatus {
         // (are there changers exposing more than one?)
         // defaults to 0 for changer that do not report transports
         self.transports
-            .get(0)
+            .first()
             .map(|t| t.element_address)
             .unwrap_or(0u16)
     }
diff --git a/pbs-tape/src/sg_pt_changer.rs b/pbs-tape/src/sg_pt_changer.rs
index 5b8596f0..3945d18f 100644
--- a/pbs-tape/src/sg_pt_changer.rs
+++ b/pbs-tape/src/sg_pt_changer.rs
@@ -850,7 +850,7 @@ mod test {
             .map(|desc| build_storage_descriptor(desc, trailing))
             .collect();
 
-        let (desc_len, address) = if let Some(el) = descs.get(0) {
+        let (desc_len, address) = if let Some(el) = descs.first() {
             (el.len() as u16, descriptors[0].address)
         } else {
             (0u16, 0u16)
diff --git a/src/server/realm_sync_job.rs b/src/server/realm_sync_job.rs
index 9094c2fa..158c2c37 100644
--- a/src/server/realm_sync_job.rs
+++ b/src/server/realm_sync_job.rs
@@ -170,7 +170,7 @@ impl LdapRealmSyncJob {
                             "userid attribute `{user_id_attribute}` not in LDAP search result"
                         )
                     })?
-                    .get(0)
+                    .first()
                     .context("userid attribute array is empty")?
                     .clone();
 
@@ -233,7 +233,7 @@ impl LdapRealmSyncJob {
         existing_user: Option<&User>,
     ) -> User {
         let lookup = |attribute: &str, ldap_attribute: Option<&String>, schema: &'static Schema| {
-            let value = result.attributes.get(ldap_attribute?)?.get(0)?;
+            let value = result.attributes.get(ldap_attribute?)?.first()?;
             let schema = schema.unwrap_string_schema();
 
             if let Err(e) = schema.check_constraints(value) {
-- 
2.39.2





  parent reply	other threads:[~2024-02-12 13:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-12 13:17 [pbs-devel] [PATCH backup 01/13] docs: remove redundant explicit link target Maximiliano Sandoval
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 02/13] remove redundant guards Maximiliano Sandoval
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 03/13] remove needless borrows Maximiliano Sandoval
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 04/13] media_catalog: use stream_position Maximiliano Sandoval
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 05/13] use or_default instead of or_insert_with(Default::default) Maximiliano Sandoval
2024-02-12 13:17 ` Maximiliano Sandoval [this message]
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 07/13] datastore: use is_{err, some} rather than match {Ok, Some}(_) Maximiliano Sandoval
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 08/13] snapshot_reader: use Rc for structs that are not Send+Sync Maximiliano Sandoval
2024-02-13  9:20   ` Fabian Grünbichler
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 09/13] pxar: elide explicit lifetime Maximiliano Sandoval
2024-02-13  9:04 ` [pbs-devel] [PATCH backup 01/13] docs: remove redundant explicit link target Maximiliano Sandoval
2024-02-13  9:28   ` [pbs-devel] partially-applied: " Fabian Grünbichler

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=20240212131734.454966-6-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