Skip to content

Commit feca83a

Browse files
committed
refactor(download): use NonZero instead of NonZeroU64
1 parent f00e5d8 commit feca83a

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/download/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Easy file downloading
22
33
use std::fs::remove_file;
4-
use std::num::NonZeroU64;
4+
use std::num::NonZero;
55
use std::path::Path;
66
use std::str::FromStr;
77
use std::time::Duration;
@@ -201,9 +201,11 @@ async fn download_file_(
201201
};
202202

203203
let timeout = Duration::from_secs(match process.var("RUSTUP_DOWNLOAD_TIMEOUT") {
204-
Ok(s) => NonZeroU64::from_str(&s).context(
205-
"invalid value in RUSTUP_DOWNLOAD_TIMEOUT -- must be a natural number greater than zero",
206-
)?.get(),
204+
Ok(s) => NonZero::from_str(&s)
205+
.context(
206+
"invalid value in RUSTUP_DOWNLOAD_TIMEOUT -- must be a natural number greater than zero",
207+
)?
208+
.get(),
207209
Err(_) => 180,
208210
});
209211

src/process.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::ffi::OsString;
22
use std::fmt::Debug;
33
use std::io;
44
use std::io::IsTerminal;
5-
use std::num::NonZeroU64;
5+
use std::num::NonZero;
66
use std::path::PathBuf;
77
use std::str::FromStr;
88
#[cfg(feature = "test")]
@@ -189,7 +189,7 @@ impl Process {
189189

190190
pub fn concurrent_downloads(&self) -> Option<usize> {
191191
let s = self.var("RUSTUP_CONCURRENT_DOWNLOADS").ok()?;
192-
Some(NonZeroU64::from_str(&s).ok()?.get() as usize)
192+
Some(NonZero::from_str(&s).ok()?.get())
193193
}
194194
}
195195

0 commit comments

Comments
 (0)