]> git.proxmox.com Git - rustc.git/blobdiff - src/libstd/sys/common/wtf8.rs
New upstream version 1.12.0+dfsg1
[rustc.git] / src / libstd / sys / common / wtf8.rs
index b6be85a4dfa2879b04548c74964195a5f3f8c1ce..c1b4f8a8c88c501d9dc174c8f7186001a9f37b15 100644 (file)
@@ -390,7 +390,7 @@ impl fmt::Debug for Wtf8 {
     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(())
@@ -408,7 +408,7 @@ impl fmt::Debug for Wtf8 {
                             &self.bytes[pos .. surrogate_pos]
                         )},
                     )?;
-                    write!(formatter, "\\u{{{:X}}}", surrogate)?;
+                    write!(formatter, "\\u{{{:x}}}", surrogate)?;
                     pos = surrogate_pos + 3;
                 }
             }
@@ -566,7 +566,7 @@ impl Wtf8 {
         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
         }
@@ -578,7 +578,7 @@ impl Wtf8 {
         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
         }
@@ -1064,9 +1064,9 @@ mod tests {
 
     #[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]