Skip to content

Commit

Permalink
Format invalid float message to show at least one decimal place
Browse files Browse the repository at this point in the history
  • Loading branch information
Dav1dde committed Jan 26, 2024
1 parent aecb408 commit 1d2ba6a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion serde/src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ impl<'a> fmt::Display for Unexpected<'a> {
Bool(b) => write!(formatter, "boolean `{}`", b),
Unsigned(i) => write!(formatter, "integer `{}`", i),
Signed(i) => write!(formatter, "integer `{}`", i),
Float(f) => write!(formatter, "floating point `{}`", f),
Float(f) => write!(formatter, "floating point `{:.1}`", f),
Char(c) => write!(formatter, "character `{}`", c),
Str(s) => write!(formatter, "string {:?}", s),
Bytes(_) => write!(formatter, "byte array"),
Expand Down
2 changes: 1 addition & 1 deletion test_suite/tests/test_de_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,7 @@ fn test_number_from_string() {
fn test_integer_from_float() {
assert_de_tokens_error::<isize>(
&[Token::F32(0.0)],
"invalid type: floating point `0`, expected isize",
"invalid type: floating point `0.0`, expected isize",
);
}

Expand Down

0 comments on commit 1d2ba6a

Please sign in to comment.