access first element with first() rather than get(0)

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>
This commit is contained in:
Maximiliano Sandoval 2024-02-12 14:17:31 +01:00 committed by Fabian Grünbichler
parent b0a8752edd
commit 911279b4f9
3 changed files with 4 additions and 4 deletions

View File

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

View File

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

View File

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