mirror of
https://github.com/serde-rs/json.git
synced 2026-01-20 15:45:54 +00:00
Pass &str to write_string_fragment
This commit is contained in:
parent
e8a06ef631
commit
ecdc3d5ab1
@ -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<W: ?Sized>(&mut self, writer: &mut W, fragment: &[u8]) -> Result<()>
|
||||
fn write_string_fragment<W: ?Sized>(&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<W: ?Sized, F: ?Sized>(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<W: ?Sized, F: ?Sized>(writer: &mut W,
|
||||
}
|
||||
|
||||
if start != bytes.len() {
|
||||
try!(formatter.write_string_fragment(writer, &bytes[start..]));
|
||||
try!(formatter.write_string_fragment(writer, &value[start..]));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user