]> git.lizzy.rs Git - rust.git/commitdiff
unicode: Rename UnicodeChar::is_digit to is_numeric
authorBrian Anderson <banderson@mozilla.com>
Thu, 9 Oct 2014 00:15:27 +0000 (17:15 -0700)
committerBrian Anderson <banderson@mozilla.com>
Fri, 21 Nov 2014 21:17:04 +0000 (13:17 -0800)
'Numeric' is the proper name of the unicode character class,
and this frees up the word 'digit' for ascii use in libcore.

Since I'm going to rename `Char::is_digit_radix` to
`is_digit`, I am not leaving a deprecated method in place,
because that would just cause name clashes, as both
`Char` and `UnicodeChar` are in the prelude.

[breaking-change]

src/compiletest/runtest.rs
src/libcollections/str.rs
src/libcore/str.rs
src/libcoretest/char.rs
src/librustc/lint/builtin.rs
src/libstd/rt/backtrace.rs
src/libunicode/u_char.rs

index 75dc45d16eb3666ca76111c67d34e9ae06ff4527..9bf45de0a17d45deba904d9e3aa1d73cdc372bce 100644 (file)
@@ -1566,7 +1566,7 @@ fn _arm_exec_compiled_test(config: &Config,
 
     let mut exitcode: int = 0;
     for c in exitcode_out.as_slice().chars() {
-        if !c.is_digit() { break; }
+        if !c.is_numeric() { break; }
         exitcode = exitcode * 10 + match c {
             '0' ... '9' => c as int - ('0' as int),
             _ => 101,
index 9c93669b5acbd065bb5a27eb432b88ef7af9db3c..d28cdcc3f4b3409c84d6ba9d6b842711856b5809 100644 (file)
@@ -1189,7 +1189,7 @@ fn test_trim_left_chars() {
         assert_eq!("11foo1bar11".trim_left_chars('1'), "foo1bar11");
         let chars: &[char] = &['1', '2'];
         assert_eq!("12foo1bar12".trim_left_chars(chars), "foo1bar12");
-        assert_eq!("123foo1bar123".trim_left_chars(|c: char| c.is_digit()), "foo1bar123");
+        assert_eq!("123foo1bar123".trim_left_chars(|c: char| c.is_numeric()), "foo1bar123");
     }
 
     #[test]
@@ -1204,7 +1204,7 @@ fn test_trim_right_chars() {
         assert_eq!("11foo1bar11".trim_right_chars('1'), "11foo1bar");
         let chars: &[char] = &['1', '2'];
         assert_eq!("12foo1bar12".trim_right_chars(chars), "12foo1bar");
-        assert_eq!("123foo1bar123".trim_right_chars(|c: char| c.is_digit()), "123foo1bar");
+        assert_eq!("123foo1bar123".trim_right_chars(|c: char| c.is_numeric()), "123foo1bar");
     }
 
     #[test]
@@ -1219,7 +1219,7 @@ fn test_trim_chars() {
         assert_eq!("11foo1bar11".trim_chars('1'), "foo1bar");
         let chars: &[char] = &['1', '2'];
         assert_eq!("12foo1bar12".trim_chars(chars), "foo1bar");
-        assert_eq!("123foo1bar123".trim_chars(|c: char| c.is_digit()), "foo1bar");
+        assert_eq!("123foo1bar123".trim_chars(|c: char| c.is_numeric()), "foo1bar");
     }
 
     #[test]
index 68e490ecb19c44e2b233667c0cf39bfd4d4ccb72..8d26a970eb8baa9edd129923f1efa3d805ccb71b 100644 (file)
@@ -1315,7 +1315,7 @@ pub trait StrPrelude for Sized? {
     /// let v: Vec<&str> = "Mary had a little lamb".split(' ').collect();
     /// assert_eq!(v, vec!["Mary", "had", "a", "little", "lamb"]);
     ///
-    /// let v: Vec<&str> = "abc1def2ghi".split(|c: char| c.is_digit()).collect();
+    /// let v: Vec<&str> = "abc1def2ghi".split(|c: char| c.is_numeric()).collect();
     /// assert_eq!(v, vec!["abc", "def", "ghi"]);
     ///
     /// let v: Vec<&str> = "lionXXtigerXleopard".split('X').collect();
@@ -1336,7 +1336,7 @@ pub trait StrPrelude for Sized? {
     /// let v: Vec<&str> = "Mary had a little lambda".splitn(2, ' ').collect();
     /// assert_eq!(v, vec!["Mary", "had", "a little lambda"]);
     ///
-    /// let v: Vec<&str> = "abc1def2ghi".splitn(1, |c: char| c.is_digit()).collect();
+    /// let v: Vec<&str> = "abc1def2ghi".splitn(1, |c: char| c.is_numeric()).collect();
     /// assert_eq!(v, vec!["abc", "def2ghi"]);
     ///
     /// let v: Vec<&str> = "lionXXtigerXleopard".splitn(2, 'X').collect();
@@ -1368,7 +1368,7 @@ pub trait StrPrelude for Sized? {
     /// let v: Vec<&str> = "Mary had a little lamb".split(' ').rev().collect();
     /// assert_eq!(v, vec!["lamb", "little", "a", "had", "Mary"]);
     ///
-    /// let v: Vec<&str> = "abc1def2ghi".split(|c: char| c.is_digit()).rev().collect();
+    /// let v: Vec<&str> = "abc1def2ghi".split(|c: char| c.is_numeric()).rev().collect();
     /// assert_eq!(v, vec!["ghi", "def", "abc"]);
     ///
     /// let v: Vec<&str> = "lionXXtigerXleopard".split('X').rev().collect();
@@ -1386,7 +1386,7 @@ pub trait StrPrelude for Sized? {
     /// let v: Vec<&str> = "Mary had a little lamb".rsplitn(2, ' ').collect();
     /// assert_eq!(v, vec!["lamb", "little", "Mary had a"]);
     ///
-    /// let v: Vec<&str> = "abc1def2ghi".rsplitn(1, |c: char| c.is_digit()).collect();
+    /// let v: Vec<&str> = "abc1def2ghi".rsplitn(1, |c: char| c.is_numeric()).collect();
     /// assert_eq!(v, vec!["ghi", "abc1def"]);
     ///
     /// let v: Vec<&str> = "lionXXtigerXleopard".rsplitn(2, 'X').collect();
@@ -1596,7 +1596,7 @@ pub trait StrPrelude for Sized? {
     /// assert_eq!("11foo1bar11".trim_chars('1'), "foo1bar")
     /// let x: &[_] = &['1', '2'];
     /// assert_eq!("12foo1bar12".trim_chars(x), "foo1bar")
-    /// assert_eq!("123foo1bar123".trim_chars(|c: char| c.is_digit()), "foo1bar")
+    /// assert_eq!("123foo1bar123".trim_chars(|c: char| c.is_numeric()), "foo1bar")
     /// ```
     fn trim_chars<'a, C: CharEq>(&'a self, to_trim: C) -> &'a str;
 
@@ -1612,7 +1612,7 @@ pub trait StrPrelude for Sized? {
     /// assert_eq!("11foo1bar11".trim_left_chars('1'), "foo1bar11")
     /// let x: &[_] = &['1', '2'];
     /// assert_eq!("12foo1bar12".trim_left_chars(x), "foo1bar12")
-    /// assert_eq!("123foo1bar123".trim_left_chars(|c: char| c.is_digit()), "foo1bar123")
+    /// assert_eq!("123foo1bar123".trim_left_chars(|c: char| c.is_numeric()), "foo1bar123")
     /// ```
     fn trim_left_chars<'a, C: CharEq>(&'a self, to_trim: C) -> &'a str;
 
@@ -1628,7 +1628,7 @@ pub trait StrPrelude for Sized? {
     /// assert_eq!("11foo1bar11".trim_right_chars('1'), "11foo1bar")
     /// let x: &[_] = &['1', '2'];
     /// assert_eq!("12foo1bar12".trim_right_chars(x), "12foo1bar")
-    /// assert_eq!("123foo1bar123".trim_right_chars(|c: char| c.is_digit()), "123foo1bar")
+    /// assert_eq!("123foo1bar123".trim_right_chars(|c: char| c.is_numeric()), "123foo1bar")
     /// ```
     fn trim_right_chars<'a, C: CharEq>(&'a self, to_trim: C) -> &'a str;
 
index 8ec3c59da4e00fe1cf1841f4370b87c25a0214a2..2d5ca983fec70ff9958315338408f204952c50aa 100644 (file)
@@ -105,12 +105,12 @@ fn test_is_control() {
 
 #[test]
 fn test_is_digit() {
-   assert!('2'.is_digit());
-   assert!('7'.is_digit());
-   assert!(!'c'.is_digit());
-   assert!(!'i'.is_digit());
-   assert!(!'z'.is_digit());
-   assert!(!'Q'.is_digit());
+   assert!('2'.is_numeric());
+   assert!('7'.is_numeric());
+   assert!(!'c'.is_numeric());
+   assert!(!'i'.is_numeric());
+   assert!(!'z'.is_numeric());
+   assert!(!'Q'.is_numeric());
 }
 
 #[test]
index c763ac889c25d0c1cb2e9d0a021df0713329801e..00c68f42c3249d4ba8168f3c0468906c6eeecb2b 100644 (file)
@@ -920,7 +920,7 @@ fn is_snake_case(ident: ast::Ident) -> bool {
             let mut allow_underscore = true;
             ident.chars().all(|c| {
                 allow_underscore = match c {
-                    c if c.is_lowercase() || c.is_digit() => true,
+                    c if c.is_lowercase() || c.is_numeric() => true,
                     '_' if allow_underscore => false,
                     _ => return false,
                 };
index 107518ef27c9d818457f6088728217a2e306b311..81022994387493e41d8e573196b3f0945441a538 100644 (file)
@@ -71,7 +71,7 @@ fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
         while valid {
             let mut i = 0;
             for c in chars {
-                if c.is_digit() {
+                if c.is_numeric() {
                     i = i * 10 + c as uint - '0' as uint;
                 } else {
                     break
@@ -101,7 +101,7 @@ fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
                 first = false;
             }
             let mut rest = s;
-            while rest.char_at(0).is_digit() {
+            while rest.char_at(0).is_numeric() {
                 rest = rest.slice_from(1);
             }
             let i: uint = from_str(s.slice_to(s.len() - rest.len())).unwrap();
index bac8b21ea68bb832401e2e4f4fbff42c015cc912..4bedc6f21f47cd932bd9b157724367403da84fb6 100644 (file)
@@ -217,7 +217,7 @@ pub trait UnicodeChar {
     fn is_control(&self) -> bool;
 
     /// Indicates whether the character is numeric (Nd, Nl, or No).
-    fn is_digit(&self) -> bool;
+    fn is_numeric(&self) -> bool;
 
     /// Converts a character to its lowercase equivalent.
     ///
@@ -281,7 +281,7 @@ fn is_alphanumeric(&self) -> bool { is_alphanumeric(*self) }
 
     fn is_control(&self) -> bool { is_control(*self) }
 
-    fn is_digit(&self) -> bool { is_digit(*self) }
+    fn is_numeric(&self) -> bool { is_digit(*self) }
 
     fn to_lowercase(&self) -> char { to_lowercase(*self) }