From e55e7d304b91c0777a13bbd6d861c033f6ccb583 Mon Sep 17 00:00:00 2001 From: daxpedda Date: Mon, 9 Dec 2024 12:26:25 +0100 Subject: [PATCH] Track upstream `Instant` and `SystemTime` sources --- .github/upstream-sources.json | 7 +++++++ src/time/instant.rs | 2 ++ src/time/system_time.rs | 12 ++++++------ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/upstream-sources.json b/.github/upstream-sources.json index 7fc664e..b5abe53 100644 --- a/.github/upstream-sources.json +++ b/.github/upstream-sources.json @@ -3,6 +3,13 @@ { "owner": "rust-lang", "repo": "libm", "tag": "libm-v0.2.11", "path": "src/math/copysign.rs" }, { "owner": "rust-lang", "repo": "libm", "tag": "libm-v0.2.11", "path": "src/math/round.rs" }, { "owner": "rust-lang", "repo": "rust", "tag": "1.83.0", "path": "library/core/src/time.rs" }, + { "owner": "rust-lang", "repo": "rust", "tag": "1.83.0", "path": "library/std/src/time.rs" }, + { + "owner": "rust-lang", + "repo": "rust", + "tag": "1.83.0", + "path": "library/std/src/sys/pal/unsupported/time.rs" + }, { "owner": "rust-lang", "repo": "rust", diff --git a/src/time/instant.rs b/src/time/instant.rs index 2411261..715c3cf 100644 --- a/src/time/instant.rs +++ b/src/time/instant.rs @@ -1,4 +1,6 @@ //! Re-implementation of [`std::time::Instant`]. +//! +//! See . #![cfg_attr( not(feature = "std"), doc = "", diff --git a/src/time/system_time.rs b/src/time/system_time.rs index 866277f..f6a0e8c 100644 --- a/src/time/system_time.rs +++ b/src/time/system_time.rs @@ -1,5 +1,6 @@ //! Re-implementation of [`std::time::SystemTime`]. - +//! +//! See . #![cfg_attr( not(feature = "std"), doc = "", @@ -56,11 +57,10 @@ impl SystemTime { )] #[allow(clippy::missing_errors_doc, clippy::trivially_copy_pass_by_ref)] pub fn duration_since(&self, earlier: Self) -> Result { - if self.0 < earlier.0 { - Err(SystemTimeError(earlier.0 - self.0)) - } else { - Ok(self.0 - earlier.0) - } + // See . + self.0 + .checked_sub(earlier.0) + .ok_or_else(|| SystemTimeError(earlier.0 - self.0)) } /// See [`std::time::SystemTime::elapsed()`].