From bdceca164277b39d4ed05746fdeafdb337ae7ab1 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Wed, 4 Jun 2025 11:46:14 +0100 Subject: [PATCH 1/2] cargo clippy --fix --- src/common.rs | 2 +- src/crates_cache.rs | 2 +- src/publishers.rs | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common.rs b/src/common.rs index 1d9eea4..2372967 100644 --- a/src/common.rs +++ b/src/common.rs @@ -316,6 +316,6 @@ mod tests { } fn enabled(key: &str) -> bool { - var(key).map_or(false, |value| value != "0") + var(key).is_ok_and(|value| value != "0") } } diff --git a/src/crates_cache.rs b/src/crates_cache.rs index 4b04d7a..aecf317 100644 --- a/src/crates_cache.rs +++ b/src/crates_cache.rs @@ -149,7 +149,7 @@ impl CratesCache { } request.call() } - .map_err(|e| io::Error::new(ErrorKind::Other, e))?; + .map_err(io::Error::other)?; // Not modified. if response.status() == 304 { diff --git a/src/publishers.rs b/src/publishers.rs index 6140d62..bb476c0 100644 --- a/src/publishers.rs +++ b/src/publishers.rs @@ -3,7 +3,7 @@ use crate::crates_cache::{CacheState, CratesCache}; use serde::{Deserialize, Serialize}; use std::{ collections::BTreeMap, - io::{self, ErrorKind}, + io::{self}, time::Duration, }; @@ -97,7 +97,7 @@ fn get_with_retry( let mut resp = client .get(url) .call() - .map_err(|e| io::Error::new(ErrorKind::Other, e))?; + .map_err(io::Error::other)?; let mut count = 1; let mut wait = 5; @@ -111,7 +111,7 @@ fn get_with_retry( resp = client .get(url) .call() - .map_err(|e| io::Error::new(ErrorKind::Other, e))?; + .map_err(io::Error::other)?; count += 1; wait *= 3; From a66225b4aa49db6bf940ae2c38a6bb1ca1f91a90 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Wed, 4 Jun 2025 11:47:12 +0100 Subject: [PATCH 2/2] cargo fmt --- src/publishers.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/publishers.rs b/src/publishers.rs index bb476c0..3b1d048 100644 --- a/src/publishers.rs +++ b/src/publishers.rs @@ -94,10 +94,7 @@ fn get_with_retry( client: &mut RateLimitedClient, attempts: u8, ) -> Result { - let mut resp = client - .get(url) - .call() - .map_err(io::Error::other)?; + let mut resp = client.get(url).call().map_err(io::Error::other)?; let mut count = 1; let mut wait = 5; @@ -108,10 +105,7 @@ fn get_with_retry( ); std::thread::sleep(std::time::Duration::from_secs(wait)); - resp = client - .get(url) - .call() - .map_err(io::Error::other)?; + resp = client.get(url).call().map_err(io::Error::other)?; count += 1; wait *= 3;