mirror of
https://github.com/serde-rs/json.git
synced 2025-09-30 06:21:34 +00:00
Format f64 in error messages using ryu
This commit is contained in:
parent
107c2d1c42
commit
83d7bad54b
12
src/error.rs
12
src/error.rs
@ -466,10 +466,14 @@ struct JsonUnexpected<'a>(de::Unexpected<'a>);
|
||||
|
||||
impl<'a> Display for JsonUnexpected<'a> {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
if let de::Unexpected::Unit = self.0 {
|
||||
formatter.write_str("null")
|
||||
} else {
|
||||
Display::fmt(&self.0, formatter)
|
||||
match self.0 {
|
||||
de::Unexpected::Unit => formatter.write_str("null"),
|
||||
de::Unexpected::Float(value) => write!(
|
||||
formatter,
|
||||
"floating point `{}`",
|
||||
ryu::Buffer::new().format(value),
|
||||
),
|
||||
unexp => Display::fmt(&unexp, formatter),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user