Make {char, str}::escape_debug and impl Debug for {char, str} consistent
This commit is contained in:
parent
d7aa35eb1b
commit
8c89e7f3d5
@ -999,6 +999,7 @@ fn test_escape_debug() {
|
||||
assert_eq!("\u{10000}\u{10ffff}".escape_debug(), "\u{10000}\\u{10ffff}");
|
||||
assert_eq!("ab\u{200b}".escape_debug(), "ab\\u{200b}");
|
||||
assert_eq!("\u{10d4ea}\r".escape_debug(), "\\u{10d4ea}\\r");
|
||||
assert_eq!("\u{301}a\u{301}bé\u{e000}".escape_debug(), "\\u{301}a\\u{301}bé\\u{e000}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1844,14 +1844,8 @@ impl Display for str {
|
||||
impl Debug for char {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||
f.write_char('\'')?;
|
||||
if self.is_nonspacing_mark() {
|
||||
for c in self.escape_unicode() {
|
||||
f.write_char(c)?
|
||||
}
|
||||
} else {
|
||||
for c in self.escape_debug() {
|
||||
f.write_char(c)?
|
||||
}
|
||||
for c in self.escape_debug() {
|
||||
f.write_char(c)?
|
||||
}
|
||||
f.write_char('\'')
|
||||
}
|
||||
|
@ -181,19 +181,12 @@ fn test_escape_debug() {
|
||||
assert_eq!(string('\u{ff}'), "\u{ff}");
|
||||
assert_eq!(string('\u{11b}'), "\u{11b}");
|
||||
assert_eq!(string('\u{1d4b6}'), "\u{1d4b6}");
|
||||
assert_eq!(string('\u{301}'), "'\\u{301}'"); // combining character
|
||||
assert_eq!(string('\u{200b}'),"\\u{200b}"); // zero width space
|
||||
assert_eq!(string('\u{e000}'), "\\u{e000}"); // private use 1
|
||||
assert_eq!(string('\u{100000}'), "\\u{100000}"); // private use 2
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_debug() {
|
||||
assert_eq!(format!("{:?}", 'a'), "'a'"); // ASCII character
|
||||
assert_eq!(format!("{:?}", 'é'), "'é'"); // printable character
|
||||
assert_eq!(format!("{:?}", '\u{301}'), "'\\u{301}'"); // combining character
|
||||
assert_eq!(format!("{:?}", '\u{e000}'), "'\\u{e000}'"); // private use 1
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_escape_default() {
|
||||
fn string(c: char) -> String {
|
||||
|
Loading…
x
Reference in New Issue
Block a user