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(())