Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from
Closed

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

wants to merge 1 commit into from

Conversation

Dav1dde
Copy link

@Dav1dde Dav1dde commented Jan 26, 2024

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 Dav1dde marked this pull request as draft January 26, 2024 20:40
@Dav1dde
Copy link
Author

Dav1dde commented Jan 26, 2024

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

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks anyway!

I implemented a different fix in serde-rs/json#1107 + #2682.

@Dav1dde Dav1dde deleted the decimal-place branch January 27, 2024 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants