Skip to content

Commit c4326af

Browse files
authored
Merge pull request #104 from rust-secure-code/clippy
cargo clippy --fix
2 parents 1399cc3 + a66225b commit c4326af

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,6 @@ mod tests {
316316
}
317317

318318
fn enabled(key: &str) -> bool {
319-
var(key).map_or(false, |value| value != "0")
319+
var(key).is_ok_and(|value| value != "0")
320320
}
321321
}

src/crates_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl CratesCache {
149149
}
150150
request.call()
151151
}
152-
.map_err(|e| io::Error::new(ErrorKind::Other, e))?;
152+
.map_err(io::Error::other)?;
153153

154154
// Not modified.
155155
if response.status() == 304 {

src/publishers.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::crates_cache::{CacheState, CratesCache};
33
use serde::{Deserialize, Serialize};
44
use std::{
55
collections::BTreeMap,
6-
io::{self, ErrorKind},
6+
io::{self},
77
time::Duration,
88
};
99

@@ -94,10 +94,7 @@ fn get_with_retry(
9494
client: &mut RateLimitedClient,
9595
attempts: u8,
9696
) -> Result<ureq::Response, io::Error> {
97-
let mut resp = client
98-
.get(url)
99-
.call()
100-
.map_err(|e| io::Error::new(ErrorKind::Other, e))?;
97+
let mut resp = client.get(url).call().map_err(io::Error::other)?;
10198

10299
let mut count = 1;
103100
let mut wait = 5;
@@ -108,10 +105,7 @@ fn get_with_retry(
108105
);
109106
std::thread::sleep(std::time::Duration::from_secs(wait));
110107

111-
resp = client
112-
.get(url)
113-
.call()
114-
.map_err(|e| io::Error::new(ErrorKind::Other, e))?;
108+
resp = client.get(url).call().map_err(io::Error::other)?;
115109

116110
count += 1;
117111
wait *= 3;

0 commit comments

Comments
 (0)