fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
fn write_str_escaped(f: &mut fmt::Formatter, s: &str) -> fmt::Result {
use fmt::Write;
- for c in s.chars().flat_map(|c| c.escape_default()) {
+ for c in s.chars().flat_map(|c| c.escape_debug()) {
f.write_char(c)?
}
Ok(())
&self.bytes[pos .. surrogate_pos]
)},
)?;
- write!(formatter, "\\u{{{:X}}}", surrogate)?;
+ write!(formatter, "\\u{{{:x}}}", surrogate)?;
pos = surrogate_pos + 3;
}
}
if len < 3 {
return None
}
- match ::slice_pat(&&self.bytes[(len - 3)..]) {
+ match &self.bytes[(len - 3)..] {
&[0xED, b2 @ 0xA0...0xAF, b3] => Some(decode_surrogate(b2, b3)),
_ => None
}
if len < 3 {
return None
}
- match ::slice_pat(&&self.bytes[..3]) {
+ match &self.bytes[..3] {
&[0xED, b2 @ 0xB0...0xBF, b3] => Some(decode_surrogate(b2, b3)),
_ => None
}
#[test]
fn wtf8buf_show() {
- let mut string = Wtf8Buf::from_str("a\té 💩\r");
+ let mut string = Wtf8Buf::from_str("a\té \u{7f}💩\r");
string.push(CodePoint::from_u32(0xD800).unwrap());
- assert_eq!(format!("{:?}", string), r#""a\t\u{e9} \u{1f4a9}\r\u{D800}""#);
+ assert_eq!(format!("{:?}", string), "\"a\\té \\u{7f}\u{1f4a9}\\r\\u{d800}\"");
}
#[test]