File tree Expand file tree Collapse file tree 3 files changed +10
-1
lines changed Expand file tree Collapse file tree 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 {
12791279 const MANT_MASK : $bits_ty = ( 1 << $mant_bits) - 1 ;
12801280 const EXP_MASK : $bits_ty = ( 1 << $exp_bits) - 1 ;
12811281
1282- if $secs. is_sign_negative ( ) {
1282+ if $secs < 0.0 {
12831283 return Err ( FromFloatSecsError { kind: FromFloatSecsErrorKind :: Negative } ) ;
12841284 }
12851285
Original file line number Diff line number Diff line change 101101#![ feature( provide_any) ]
102102#![ feature( utf8_chunks) ]
103103#![ feature( is_ascii_octdigit) ]
104+ #![ feature( duration_checked_float) ]
104105#![ deny( unsafe_op_in_unsafe_fn) ]
105106
106107extern crate test;
Original file line number Diff line number Diff line change @@ -467,3 +467,11 @@ fn duration_const() {
467467 const SATURATING_MUL : Duration = MAX . saturating_mul ( 2 ) ;
468468 assert_eq ! ( SATURATING_MUL , MAX ) ;
469469}
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