File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -2312,13 +2312,17 @@ impl Display for WithDecimalPoint {
23122312 }
23132313 }
23142314
2315- let mut writer = LookForDecimalPoint {
2316- formatter,
2317- has_decimal_point : false ,
2318- } ;
2319- tri ! ( write!( writer, "{}" , self . 0 ) ) ;
2320- if !writer. has_decimal_point {
2321- tri ! ( formatter. write_str( ".0" ) ) ;
2315+ if self . 0 . is_finite ( ) {
2316+ let mut writer = LookForDecimalPoint {
2317+ formatter,
2318+ has_decimal_point : false ,
2319+ } ;
2320+ tri ! ( write!( writer, "{}" , self . 0 ) ) ;
2321+ if !writer. has_decimal_point {
2322+ tri ! ( formatter. write_str( ".0" ) ) ;
2323+ }
2324+ } else {
2325+ tri ! ( write!( formatter, "{}" , self . 0 ) ) ;
23222326 }
23232327 Ok ( ( ) )
23242328 }
Original file line number Diff line number Diff line change @@ -1438,6 +1438,14 @@ fn test_integer_from_float() {
14381438 ) ;
14391439}
14401440
1441+ #[ test]
1442+ fn test_nan_no_decimal_point ( ) {
1443+ assert_de_tokens_error :: < isize > (
1444+ & [ Token :: F32 ( f32:: NAN ) ] ,
1445+ "invalid type: floating point `NaN`, expected isize" ,
1446+ ) ;
1447+ }
1448+
14411449#[ test]
14421450fn test_unit_struct_from_seq ( ) {
14431451 assert_de_tokens_error :: < UnitStruct > (
You can’t perform that action at this time.
0 commit comments