File tree 3 files changed +10
-1
lines changed
3 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -1279,7 +1279,7 @@ macro_rules! try_from_secs {
1279
1279
const MANT_MASK : $bits_ty = ( 1 << $mant_bits) - 1 ;
1280
1280
const EXP_MASK : $bits_ty = ( 1 << $exp_bits) - 1 ;
1281
1281
1282
- if $secs. is_sign_negative ( ) {
1282
+ if $secs < 0.0 {
1283
1283
return Err ( FromFloatSecsError { kind: FromFloatSecsErrorKind :: Negative } ) ;
1284
1284
}
1285
1285
Original file line number Diff line number Diff line change 101
101
#![ feature( provide_any) ]
102
102
#![ feature( utf8_chunks) ]
103
103
#![ feature( is_ascii_octdigit) ]
104
+ #![ feature( duration_checked_float) ]
104
105
#![ deny( unsafe_op_in_unsafe_fn) ]
105
106
106
107
extern crate test;
Original file line number Diff line number Diff line change @@ -467,3 +467,11 @@ fn duration_const() {
467
467
const SATURATING_MUL : Duration = MAX . saturating_mul ( 2 ) ;
468
468
assert_eq ! ( SATURATING_MUL , MAX ) ;
469
469
}
470
+
471
+ #[ test]
472
+ fn from_neg_zero ( ) {
473
+ assert_eq ! ( Duration :: try_from_secs_f32( -0.0 ) , Ok ( Duration :: ZERO ) ) ;
474
+ assert_eq ! ( Duration :: try_from_secs_f64( -0.0 ) , Ok ( Duration :: ZERO ) ) ;
475
+ assert_eq ! ( Duration :: from_secs_f32( -0.0 ) , Duration :: ZERO ) ;
476
+ assert_eq ! ( Duration :: from_secs_f64( -0.0 ) , Duration :: ZERO ) ;
477
+ }
You can’t perform that action at this time.
0 commit comments