[pbs-devel] [PATCH backup 06/13] access first element with first() rather than get(0)
Maximiliano Sandoval
m.sandoval at proxmox.com
Mon Feb 12 14:17:31 CET 2024
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 at 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
More information about the pbs-devel
mailing list