Skip to content

Commit 3e2a4b2

Browse files
committed
clippy lint in Instant::duration_since
Fixes a new CI error in Rust 1.94: error: manual saturating arithmetic --> src/time/instant.rs:33:30 | 33 | Duration::from_nanos(self.0.checked_sub(earlier.0).unwrap_or_default()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `self.0.saturating_sub(earlier.0)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.94.0/index.html#manual_saturating_arithmetic = note: `-D clippy::manual-saturating-arithmetic` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::manual_saturating_arithmetic)]`
1 parent 529fc0d commit 3e2a4b2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/time/instant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl Instant {
3030
/// Returns the amount of time elapsed from another instant to this one, or zero duration if
3131
/// that instant is later than this one.
3232
pub fn duration_since(&self, earlier: Instant) -> Duration {
33-
Duration::from_nanos(self.0.checked_sub(earlier.0).unwrap_or_default())
33+
Duration::from_nanos(self.0.saturating_sub(earlier.0))
3434
}
3535

3636
/// Returns the amount of time elapsed since this instant.

0 commit comments

Comments
 (0)