diff options
| author | varkor <github@varkor.com> | 2018-05-16 23:20:22 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2018-05-21 18:57:54 +0100 |
| commit | 8c89e7f3d58ff110aa4de64aef8ef29f78ebf456 (patch) | |
| tree | 301f03ef2884b409ab53eeeb0bdca89b254cfba2 /src | |
| parent | d7aa35eb1bdc61db0842ab81f6c96f24897e61ad (diff) | |
| download | rust-8c89e7f3d58ff110aa4de64aef8ef29f78ebf456.tar.gz rust-8c89e7f3d58ff110aa4de64aef8ef29f78ebf456.zip | |
Make {char, str}::escape_debug and impl Debug for {char, str} consistent
Diffstat (limited to 'src')
| -rw-r--r-- | src/liballoc/tests/str.rs | 1 | ||||
| -rw-r--r-- | src/libcore/fmt/mod.rs | 10 | ||||
| -rw-r--r-- | src/libcore/tests/char.rs | 9 |
3 files changed, 4 insertions, 16 deletions
diff --git a/src/liballoc/tests/str.rs b/src/liballoc/tests/str.rs index 1a47e5433ea..2f38c8b3ae2 100644 --- a/src/liballoc/tests/str.rs +++ b/src/liballoc/tests/str.rs @@ -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] diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 1cfde513102..5820fe58932 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -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('\'') } diff --git a/src/libcore/tests/char.rs b/src/libcore/tests/char.rs index 76f28d493ab..d19e3b52769 100644 --- a/src/libcore/tests/char.rs +++ b/src/libcore/tests/char.rs @@ -181,20 +181,13 @@ 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 { let iter: String = c.escape_default().collect(); |
