File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -310,6 +310,9 @@ impl Duration {
310310
311311 /// Creates a new Duration from the specified number of nanoseconds.
312312 ///
313+ /// # Panics
314+ ///
315+ /// Panics if the given number of weeks overflows the `Duration` size.
313316 /// Use this function if you need to specify time greater than what can fit in u64
314317 /// (around 584 years).
315318 ///
@@ -324,7 +327,7 @@ impl Duration {
324327 #[ unstable( feature = "duration_from_nanos_u128" , issue = "139201" ) ]
325328 pub const fn from_nanos_u128 ( nanos : u128 ) -> Duration {
326329 const NANOS_PER_SEC : u128 = self :: NANOS_PER_SEC as u128 ;
327- let secs = u64:: try_from ( nanos / NANOS_PER_SEC ) . unwrap_or ( u64:: MAX ) ;
330+ let secs : u64 = ( nanos/ NANOS_PER_SEC ) as u64 ;
328331 let subsec_nanos = ( nanos % NANOS_PER_SEC ) as u32 ;
329332 // SAFETY: x % 1_000_000_000 < 1_000_000_000
330333 let subsec_nanos = unsafe { Nanoseconds :: new_unchecked ( subsec_nanos) } ;
You can’t perform that action at this time.
0 commit comments