about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrea Canciani <ranma42@gmail.com>2016-01-04 17:49:16 +0100
committerAndrea Canciani <ranma42@gmail.com>2016-01-04 17:58:50 +0100
commit3fff63400b3032f64cdd3d0743d9a9c2cab019b4 (patch)
treeea2634178d060c6798e54e26aeee8c39170530af
parentaa77f39ccf2786b864206f24e85661eee63022a8 (diff)
downloadrust-3fff63400b3032f64cdd3d0743d9a9c2cab019b4.tar.gz
rust-3fff63400b3032f64cdd3d0743d9a9c2cab019b4.zip
Update librustc_unicode/tables.rs
with a new version generated by src/etc/unicode.py.
-rw-r--r--src/librustc_unicode/tables.rs34
1 files changed, 15 insertions, 19 deletions
diff --git a/src/librustc_unicode/tables.rs b/src/librustc_unicode/tables.rs
index cf75cf52577..a147bea791c 100644
--- a/src/librustc_unicode/tables.rs
+++ b/src/librustc_unicode/tables.rs
@@ -16,13 +16,18 @@
 /// that the unicode parts of `CharExt` and `UnicodeStrPrelude` traits are based on.
 pub const UNICODE_VERSION: (u64, u64, u64) = (8, 0, 0);
 
-fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
+fn bsearch_range_table(c: char, r: &'static [(char, char)]) -> bool {
     use core::cmp::Ordering::{Equal, Less, Greater};
-    r.binary_search_by(|&(lo,hi)| {
-        if lo <= c && c <= hi { Equal }
-        else if hi < c { Less }
-        else { Greater }
-    }).is_ok()
+    r.binary_search_by(|&(lo, hi)| {
+         if c < lo {
+             Greater
+         } else if hi < c {
+             Less
+         } else {
+             Equal
+         }
+     })
+     .is_ok()
 }
 
 pub mod general_category {
@@ -1188,34 +1193,25 @@ pub mod property {
 }
 
 pub mod conversions {
-    use core::cmp::Ordering::{Equal, Less, Greater};
     use core::option::Option;
     use core::option::Option::{Some, None};
-    use core::result::Result::{Ok, Err};
 
     pub fn to_lower(c: char) -> [char; 3] {
         match bsearch_case_table(c, to_lowercase_table) {
-          None        => [c, '\0', '\0'],
-          Some(index) => to_lowercase_table[index].1
+            None        => [c, '\0', '\0'],
+            Some(index) => to_lowercase_table[index].1,
         }
     }
 
     pub fn to_upper(c: char) -> [char; 3] {
         match bsearch_case_table(c, to_uppercase_table) {
             None        => [c, '\0', '\0'],
-            Some(index) => to_uppercase_table[index].1
+            Some(index) => to_uppercase_table[index].1,
         }
     }
 
     fn bsearch_case_table(c: char, table: &'static [(char, [char; 3])]) -> Option<usize> {
-        match table.binary_search_by(|&(key, _)| {
-            if c == key { Equal }
-            else if key < c { Less }
-            else { Greater }
-        }) {
-            Ok(i) => Some(i),
-            Err(_) => None,
-        }
+        table.binary_search_by(|&(key, _)| key.cmp(&c)).ok()
     }
 
     const to_lowercase_table: &'static [(char, [char; 3])] = &[