From f0c87fbd4c05bd5841c4cc1f323b28fc722b9196 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Fri, 1 May 2015 07:43:48 -0700 Subject: [PATCH] Format flats with `Debug` to properly print "-0.0". --- src/json/ser.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/json/ser.rs b/src/json/ser.rs index a6fc2070..824af96a 100644 --- a/src/json/ser.rs +++ b/src/json/ser.rs @@ -418,7 +418,7 @@ fn fmt_f32_or_null(wr: &mut W, value: f32) -> io::Result<()> match value.classify() { FpCategory::Nan | FpCategory::Infinite => wr.write_all(b"null"), _ => { - let s = value.to_string(); + let s = format!("{:?}", value); try!(wr.write_all(s.as_bytes())); if !s.contains('.') { try!(wr.write_all(b".0")) @@ -434,7 +434,7 @@ fn fmt_f64_or_null(wr: &mut W, value: f64) -> io::Result<()> match value.classify() { FpCategory::Nan | FpCategory::Infinite => wr.write_all(b"null"), _ => { - let s = value.to_string(); + let s = format!("{:?}", value); try!(wr.write_all(s.as_bytes())); if !s.contains('.') { try!(wr.write_all(b".0"))