about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2014-10-08 17:15:27 -0700
committerBrian Anderson <banderson@mozilla.com>2014-11-21 13:17:04 -0800
commitc2aff692fa88235d356725f98184a5ea5b52eb88 (patch)
tree07f840ccdb488f4d62cbd8ce7fefceac41c67ed1
parentac2f379abb13b249aa1e630e14fa42f9415160f8 (diff)
downloadrust-c2aff692fa88235d356725f98184a5ea5b52eb88.tar.gz
rust-c2aff692fa88235d356725f98184a5ea5b52eb88.zip
unicode: Rename UnicodeChar::is_digit to is_numeric
'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]
-rw-r--r--src/compiletest/runtest.rs2
-rw-r--r--src/libcollections/str.rs6
-rw-r--r--src/libcore/str.rs14
-rw-r--r--src/libcoretest/char.rs12
-rw-r--r--src/librustc/lint/builtin.rs2
-rw-r--r--src/libstd/rt/backtrace.rs4
-rw-r--r--src/libunicode/u_char.rs4
7 files changed, 22 insertions, 22 deletions
diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs
index 75dc45d16eb..9bf45de0a17 100644
--- a/src/compiletest/runtest.rs
+++ b/src/compiletest/runtest.rs
@@ -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,
diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs
index 9c93669b5ac..d28cdcc3f4b 100644
--- a/src/libcollections/str.rs
+++ b/src/libcollections/str.rs
@@ -1189,7 +1189,7 @@ mod tests {
         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 @@ mod tests {
         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 @@ mod tests {
         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]
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index 68e490ecb19..8d26a970eb8 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -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;
 
diff --git a/src/libcoretest/char.rs b/src/libcoretest/char.rs
index 8ec3c59da4e..2d5ca983fec 100644
--- a/src/libcoretest/char.rs
+++ b/src/libcoretest/char.rs
@@ -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]
diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs
index c763ac889c2..00c68f42c32 100644
--- a/src/librustc/lint/builtin.rs
+++ b/src/librustc/lint/builtin.rs
@@ -920,7 +920,7 @@ impl NonSnakeCase {
             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,
                 };
diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs
index 107518ef27c..81022994387 100644
--- a/src/libstd/rt/backtrace.rs
+++ b/src/libstd/rt/backtrace.rs
@@ -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();
diff --git a/src/libunicode/u_char.rs b/src/libunicode/u_char.rs
index bac8b21ea68..4bedc6f21f4 100644
--- a/src/libunicode/u_char.rs
+++ b/src/libunicode/u_char.rs
@@ -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 @@ impl UnicodeChar for char {
 
     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) }