From 3e2a4b21033302d938f9fd0e436ae43d71ee6637 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Tue, 10 Mar 2026 14:53:55 -0700 Subject: [PATCH] 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)]` --- src/time/instant.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/time/instant.rs b/src/time/instant.rs index f5beaca..6e9cf97 100644 --- a/src/time/instant.rs +++ b/src/time/instant.rs @@ -30,7 +30,7 @@ impl Instant { /// Returns the amount of time elapsed from another instant to this one, or zero duration if /// that instant is later than this one. pub fn duration_since(&self, earlier: Instant) -> Duration { - Duration::from_nanos(self.0.checked_sub(earlier.0).unwrap_or_default()) + Duration::from_nanos(self.0.saturating_sub(earlier.0)) } /// Returns the amount of time elapsed since this instant.