Skip to content

Commit

Permalink
Track upstream Instant and SystemTime sources
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Dec 9, 2024
1 parent df3a54a commit e55e7d3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
7 changes: 7 additions & 0 deletions .github/upstream-sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/time/instant.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! Re-implementation of [`std::time::Instant`].
//!
//! See <https://github.com/rust-lang/rust/blob/1.83.0/library/std/src/time.rs#L271-L468>.
#![cfg_attr(
not(feature = "std"),
doc = "",
Expand Down
12 changes: 6 additions & 6 deletions src/time/system_time.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Re-implementation of [`std::time::SystemTime`].
//!
//! See <https://github.com/rust-lang/rust/blob/1.83.0/library/std/src/time.rs#L470-L707>.
#![cfg_attr(
not(feature = "std"),
doc = "",
Expand Down Expand Up @@ -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<Duration, SystemTimeError> {
if self.0 < earlier.0 {
Err(SystemTimeError(earlier.0 - self.0))
} else {
Ok(self.0 - earlier.0)
}
// See <https://github.com/rust-lang/rust/blob/1.83.0/library/std/src/sys/pal/unsupported/time.rs#L34-L36>.
self.0
.checked_sub(earlier.0)
.ok_or_else(|| SystemTimeError(earlier.0 - self.0))
}

/// See [`std::time::SystemTime::elapsed()`].
Expand Down

0 comments on commit e55e7d3

Please sign in to comment.