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 {
2312
2312
}
2313
2313
}
2314
2314
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 ) ) ;
2322
2326
}
2323
2327
Ok ( ( ) )
2324
2328
}
Original file line number Diff line number Diff line change @@ -1438,6 +1438,14 @@ fn test_integer_from_float() {
1438
1438
) ;
1439
1439
}
1440
1440
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
+
1441
1449
#[ test]
1442
1450
fn test_unit_struct_from_seq ( ) {
1443
1451
assert_de_tokens_error :: < UnitStruct > (
You can’t perform that action at this time.
0 commit comments