serde-rs / serde

Serialization framework for Rust
https://serde.rs/
Apache License 2.0
8.82k stars 748 forks source link

Format invalid float message to show at least one decimal place #2679

Closed Dav1dde closed 5 months ago

Dav1dde commented 5 months ago

It can be confusing at first when deserializing (e.g. JSON) and getting an error like:

invalid type: floating point 3, expected u32

It shows a valid integer but it is actually a float.

Changes the error to always show at least one decimal place to avoid confusion.

Dav1dde commented 5 months ago

Nevermind sorry for the noise, didn't realize format does not support formatting with a minimum precision, only maximum.