From 279dea8167c3ba792483411417ce6f8599e45302 Mon Sep 17 00:00:00 2001 From: Artemis Tosini Date: Mon, 8 Jul 2024 03:26:02 +0000 Subject: [PATCH] nardl: fix some warnings --- rust/nardl/src/main.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/rust/nardl/src/main.rs b/rust/nardl/src/main.rs index 95ca93d..43bddb3 100644 --- a/rust/nardl/src/main.rs +++ b/rust/nardl/src/main.rs @@ -31,7 +31,7 @@ async fn main() -> eyre::Result<()> { let cache_base_urls = SUBSTITUERS .iter() - .map(|url| reqwest::Url::parse(*url)) + .map(|url| reqwest::Url::parse(url)) .collect::, _>>()?; let output_path = Path::new(OUTPUT); @@ -52,9 +52,9 @@ async fn main() -> eyre::Result<()> { let trusted_keys = KEYS .iter() .map(|key| -> eyre::Result<_> { - let (name, public_str) = key.split_once(":").ok_or_eyre("Key has no name")?; + let (name, public_str) = key.split_once(':').ok_or_eyre("Key has no name")?; let public_bytes = data_encoding::BASE64_NOPAD - .decode(public_str.trim_end_matches("=").as_bytes()) + .decode(public_str.trim_end_matches('=').as_bytes()) .wrap_err("Invalid base64 in key")?; Ok(( name, @@ -89,7 +89,7 @@ async fn main() -> eyre::Result<()> { log::trace!("narinfo {}: {:?}", cache, parsed); - if &parsed.store_dir != store_dir.to_str().unwrap() { + if parsed.store_dir != store_dir.to_str().unwrap() { eyre::bail!("Cache {} has a different store directory", cache); } } @@ -107,12 +107,12 @@ async fn main() -> eyre::Result<()> { log::debug!("Requesting output {}", output); let (fingerprint, _) = &output - .split_once("-") + .split_once('-') .ok_or_else(|| eyre::eyre!("Invalid output name {}", output))?; // Parse, verify, and handle narinfo let (narinfo_text, cache_base_url) = - get_narinfo(client.clone(), cache_base_urls.as_slice(), &fingerprint) + get_narinfo(client.clone(), cache_base_urls.as_slice(), fingerprint) .await .wrap_err_with(|| format!("While processing {}", output))?; let narinfo_parsed = narinfo::NarInfo::parse(&narinfo_text).unwrap(); @@ -176,7 +176,7 @@ async fn main() -> eyre::Result<()> { let (hash_algorithm, hash_expected) = narinfo_parsed .nar_hash .as_ref() - .split_once(":") + .split_once(':') .ok_or_eyre("Invalid hash in nar")?; if hash_algorithm != "sha256" { @@ -197,7 +197,7 @@ async fn main() -> eyre::Result<()> { let hash_found = hasher.finalize(); - if &nix_base32::to_nix_base32(hash_found.as_ref()) != hash_expected { + if nix_base32::to_nix_base32(hash_found.as_ref()) != hash_expected { eyre::bail!("Incorrect hash when downloading {}", output) } } @@ -205,7 +205,6 @@ async fn main() -> eyre::Result<()> { Ok(()) } -#[must_use] async fn get_narinfo<'a>( client: reqwest::Client, cache_base_urls: &'a [reqwest::Url], @@ -282,7 +281,7 @@ fn verify_signature( ); log::trace!("narinfo fingerprint: `{}`", fingerprint); - key.verify_strict(&fingerprint.as_bytes(), &signature) + key.verify_strict(fingerprint.as_bytes(), &signature) .wrap_err("Invalid signature")?; return Ok(()); }