We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9bfe135 commit 860045cCopy full SHA for 860045c
library/core/src/time.rs
@@ -324,7 +324,7 @@ impl Duration {
324
#[unstable(feature = "duration_from_nanos_u128", issue = "139201")]
325
pub const fn from_nanos_u128(nanos: u128) -> Duration {
326
const NANOS_PER_SEC: u128 = self::NANOS_PER_SEC as u128;
327
- let secs = nanos / NANOS_PER_SEC;
+ let secs = u64::try_from(nanos / NANOS_PER_SEC).unwrap_or(u64::MAX);
328
let subsec_nanos = (nanos % NANOS_PER_SEC) as u32;
329
// SAFETY: x % 1_000_000_000 < 1_000_000_000
330
let subsec_nanos = unsafe { Nanoseconds::new_unchecked(subsec_nanos) };
0 commit comments