summaryrefslogtreecommitdiff
path: root/src/sys/time.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys/time.rs')
-rw-r--r--src/sys/time.rs32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/sys/time.rs b/src/sys/time.rs
index 0042c450..a1894e4d 100644
--- a/src/sys/time.rs
+++ b/src/sys/time.rs
@@ -261,8 +261,7 @@ impl TimeValLike for TimeSpec {
fn seconds(seconds: i64) -> TimeSpec {
assert!(
(TS_MIN_SECONDS..=TS_MAX_SECONDS).contains(&seconds),
- "TimeSpec out of bounds; seconds={}",
- seconds
+ "TimeSpec out of bounds; seconds={seconds}",
);
let mut ts = zero_init_timespec();
ts.tv_sec = seconds as time_t;
@@ -428,20 +427,20 @@ impl fmt::Display for TimeSpec {
let sec = abs.tv_sec();
- write!(f, "{}", sign)?;
+ write!(f, "{sign}")?;
if abs.tv_nsec() == 0 {
- if abs.tv_sec() == 1 {
- write!(f, "{} second", sec)?;
+ if sec == 1 {
+ write!(f, "1 second")?;
} else {
- write!(f, "{} seconds", sec)?;
+ write!(f, "{sec} seconds")?;
}
} else if abs.tv_nsec() % 1_000_000 == 0 {
- write!(f, "{}.{:03} seconds", sec, abs.tv_nsec() / 1_000_000)?;
+ write!(f, "{sec}.{:03} seconds", abs.tv_nsec() / 1_000_000)?;
} else if abs.tv_nsec() % 1_000 == 0 {
- write!(f, "{}.{:06} seconds", sec, abs.tv_nsec() / 1_000)?;
+ write!(f, "{sec}.{:06} seconds", abs.tv_nsec() / 1_000)?;
} else {
- write!(f, "{}.{:09} seconds", sec, abs.tv_nsec())?;
+ write!(f, "{sec}.{:09} seconds", abs.tv_nsec())?;
}
Ok(())
@@ -497,8 +496,7 @@ impl TimeValLike for TimeVal {
fn seconds(seconds: i64) -> TimeVal {
assert!(
(TV_MIN_SECONDS..=TV_MAX_SECONDS).contains(&seconds),
- "TimeVal out of bounds; seconds={}",
- seconds
+ "TimeVal out of bounds; seconds={seconds}"
);
#[cfg_attr(target_env = "musl", allow(deprecated))]
// https://github.com/rust-lang/libc/issues/1848
@@ -662,18 +660,18 @@ impl fmt::Display for TimeVal {
let sec = abs.tv_sec();
- write!(f, "{}", sign)?;
+ write!(f, "{sign}")?;
if abs.tv_usec() == 0 {
- if abs.tv_sec() == 1 {
- write!(f, "{} second", sec)?;
+ if sec == 1 {
+ write!(f, "1 second")?;
} else {
- write!(f, "{} seconds", sec)?;
+ write!(f, "{sec} seconds")?;
}
} else if abs.tv_usec() % 1000 == 0 {
- write!(f, "{}.{:03} seconds", sec, abs.tv_usec() / 1000)?;
+ write!(f, "{sec}.{:03} seconds", abs.tv_usec() / 1000)?;
} else {
- write!(f, "{}.{:06} seconds", sec, abs.tv_usec())?;
+ write!(f, "{sec}.{:06} seconds", abs.tv_usec())?;
}
Ok(())