summary refs log tree commit diff
path: root/src/libcore/char
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2018-04-12 11:39:18 +0100
committervarkor <github@varkor.com>2018-05-21 18:57:54 +0100
commit4694d20170e1a67f8a801c1f6dda11473d6fef77 (patch)
treefcb2198b890657cdc7c7a7a26177eb69f07f4ee6 /src/libcore/char
parentb72faf5795681352b5fba83dce91ee24c22e71c8 (diff)
downloadrust-4694d20170e1a67f8a801c1f6dda11473d6fef77.tar.gz
rust-4694d20170e1a67f8a801c1f6dda11473d6fef77.zip
Escape combining characters in escape_debug
Diffstat (limited to 'src/libcore/char')
-rw-r--r--src/libcore/char/methods.rs26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/libcore/char/methods.rs b/src/libcore/char/methods.rs
index 374adafef64..c170e0c1ba1 100644
--- a/src/libcore/char/methods.rs
+++ b/src/libcore/char/methods.rs
@@ -229,8 +229,8 @@ impl char {
             '\r' => EscapeDefaultState::Backslash('r'),
             '\n' => EscapeDefaultState::Backslash('n'),
             '\\' | '\'' | '"' => EscapeDefaultState::Backslash(self),
-            c if is_printable(c) => EscapeDefaultState::Char(c),
-            c => EscapeDefaultState::Unicode(c.escape_unicode()),
+            _ if is_printable(self) => EscapeDefaultState::Char(self),
+            _ => EscapeDefaultState::Unicode(self.escape_unicode()),
         };
         EscapeDebug(EscapeDefault { state: init_state })
     }
@@ -692,6 +692,28 @@ impl char {
         general_category::Cc(self)
     }
 
+    /// Returns true if this `char` is a nonspacing mark code point, and false otherwise.
+    ///
+    /// 'Nonspacing mark code point' is defined in terms of the Unicode General
+    /// Category `Mn`.
+    ///
+    /// # Examples
+    ///
+    /// Basic usage:
+    ///
+    /// ```
+    /// // U+0301, COMBINING ACUTE ACCENT
+    /// assert!('\u{301}'.is_nonspacing_mark());
+    /// assert!(!'e'.is_nonspacing_mark());
+    /// ```
+    #[unstable(feature = "rustc_private",
+               reason = "mainly needed for compiler internals",
+               issue = "27812")]
+    #[inline]
+    pub fn is_nonspacing_mark(self) -> bool {
+        general_category::Mn(self)
+    }
+
     /// Returns true if this `char` is numeric, and false otherwise.
     ///
     /// 'Numeric'-ness is defined in terms of the Unicode General Categories