json/tests/regression/issue1004.rs
David Tolnay ce53b862b9
Fix needless_borrow clippy lint in test
error: the borrowed expression implements the required traits
     --> tests/regression/issue1004.rs:6:38
      |
    6 |     let value = serde_json::to_value(&float).unwrap();
      |                                      ^^^^^^ help: change this to: `float`
      |
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
      = note: `-D clippy::needless-borrow` implied by `-D clippy::all`
2023-03-27 10:11:48 -07:00

13 lines
362 B
Rust

#![cfg(feature = "arbitrary_precision")]
#[test]
fn test() {
let float = 5.55f32;
let value = serde_json::to_value(float).unwrap();
let json = serde_json::to_string(&value).unwrap();
// If the f32 were cast to f64 by Value before serialization, then this
// would incorrectly serialize as 5.550000190734863.
assert_eq!(json, "5.55");
}