File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change 37
37
#![ feature( duration_constants) ]
38
38
#![ feature( duration_constructors) ]
39
39
#![ feature( duration_constructors_lite) ]
40
+ #![ feature( duration_from_nanos_u128) ]
40
41
#![ feature( error_generic_member_access) ]
41
42
#![ feature( exact_div) ]
42
43
#![ feature( exact_size_is_empty) ]
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ fn from_weeks_overflow() {
48
48
#[ test]
49
49
#[ should_panic]
50
50
fn from_nanos_u128_overflow ( ) {
51
- let overflow = ( u64:: MAX * NANOS_PER_SEC ) + ( NANOS_PER_SEC - 1 ) + 1 ;
51
+ let overflow = ( u64:: MAX as u128 * 1_000_000_000 ) + ( 1_000_000_000 - 1 ) + 1 ;
52
52
let _ = Duration :: from_nanos_u128 ( overflow) ;
53
53
}
54
54
@@ -535,6 +535,9 @@ fn duration_const() {
535
535
const FROM_NANOS : Duration = Duration :: from_nanos ( 1_000_000_000 ) ;
536
536
assert_eq ! ( FROM_NANOS , Duration :: SECOND ) ;
537
537
538
+ const FROM_NANOS_U128 : Duration = Duration :: from_nanos_u128 ( NANOS ) ;
539
+ assert_eq ! ( FROM_NANOS_U128 , Duration :: SECOND ) ;
540
+
538
541
const MAX : Duration = Duration :: new ( u64:: MAX , 999_999_999 ) ;
539
542
540
543
const CHECKED_ADD : Option < Duration > = MAX . checked_add ( Duration :: SECOND ) ;
You can’t perform that action at this time.
0 commit comments