Skip to content

Commit 3fff634

Browse files
committed
Update librustc_unicode/tables.rs
with a new version generated by src/etc/unicode.py.
1 parent aa77f39 commit 3fff634

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

src/librustc_unicode/tables.rs

+15-19
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@
1616
/// that the unicode parts of `CharExt` and `UnicodeStrPrelude` traits are based on.
1717
pub const UNICODE_VERSION: (u64, u64, u64) = (8, 0, 0);
1818

19-
fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
19+
fn bsearch_range_table(c: char, r: &'static [(char, char)]) -> bool {
2020
use core::cmp::Ordering::{Equal, Less, Greater};
21-
r.binary_search_by(|&(lo,hi)| {
22-
if lo <= c && c <= hi { Equal }
23-
else if hi < c { Less }
24-
else { Greater }
25-
}).is_ok()
21+
r.binary_search_by(|&(lo, hi)| {
22+
if c < lo {
23+
Greater
24+
} else if hi < c {
25+
Less
26+
} else {
27+
Equal
28+
}
29+
})
30+
.is_ok()
2631
}
2732

2833
pub mod general_category {
@@ -1188,34 +1193,25 @@ pub mod property {
11881193
}
11891194

11901195
pub mod conversions {
1191-
use core::cmp::Ordering::{Equal, Less, Greater};
11921196
use core::option::Option;
11931197
use core::option::Option::{Some, None};
1194-
use core::result::Result::{Ok, Err};
11951198

11961199
pub fn to_lower(c: char) -> [char; 3] {
11971200
match bsearch_case_table(c, to_lowercase_table) {
1198-
None => [c, '\0', '\0'],
1199-
Some(index) => to_lowercase_table[index].1
1201+
None => [c, '\0', '\0'],
1202+
Some(index) => to_lowercase_table[index].1,
12001203
}
12011204
}
12021205

12031206
pub fn to_upper(c: char) -> [char; 3] {
12041207
match bsearch_case_table(c, to_uppercase_table) {
12051208
None => [c, '\0', '\0'],
1206-
Some(index) => to_uppercase_table[index].1
1209+
Some(index) => to_uppercase_table[index].1,
12071210
}
12081211
}
12091212

12101213
fn bsearch_case_table(c: char, table: &'static [(char, [char; 3])]) -> Option<usize> {
1211-
match table.binary_search_by(|&(key, _)| {
1212-
if c == key { Equal }
1213-
else if key < c { Less }
1214-
else { Greater }
1215-
}) {
1216-
Ok(i) => Some(i),
1217-
Err(_) => None,
1218-
}
1214+
table.binary_search_by(|&(key, _)| key.cmp(&c)).ok()
12191215
}
12201216

12211217
const to_lowercase_table: &'static [(char, [char; 3])] = &[

0 commit comments

Comments
 (0)