From ecdc3d5ab1507769e2c8191cb9a486bd020ffe95 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 27 Feb 2017 20:19:44 -0800 Subject: [PATCH] Pass &str to write_string_fragment --- json/src/ser.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/json/src/ser.rs b/json/src/ser.rs index 39a061a..bf7c7fb 100644 --- a/json/src/ser.rs +++ b/json/src/ser.rs @@ -956,10 +956,10 @@ pub trait Formatter { /// Writes a string fragment that doesn't need any escaping to the /// specified writer. #[inline] - fn write_string_fragment(&mut self, writer: &mut W, fragment: &[u8]) -> Result<()> + fn write_string_fragment(&mut self, writer: &mut W, fragment: &str) -> Result<()> where W: io::Write { - writer.write_all(fragment).map_err(From::from) + writer.write_all(fragment.as_bytes()).map_err(From::from) } /// Writes a character escape code to the specified writer. @@ -1248,7 +1248,7 @@ fn format_escaped_str_contents(writer: &mut W, } if start < i { - try!(formatter.write_string_fragment(writer, &bytes[start..i])); + try!(formatter.write_string_fragment(writer, &value[start..i])); } let char_escape = CharEscape::from_escape_table(escape, byte); @@ -1258,7 +1258,7 @@ fn format_escaped_str_contents(writer: &mut W, } if start != bytes.len() { - try!(formatter.write_string_fragment(writer, &bytes[start..])); + try!(formatter.write_string_fragment(writer, &value[start..])); } Ok(())