diff options
| author | Andrea Canciani <ranma42@gmail.com> | 2016-01-04 17:29:41 +0100 |
|---|---|---|
| committer | Andrea Canciani <ranma42@gmail.com> | 2016-01-04 17:51:12 +0100 |
| commit | cf3fcf7758f4e568a5b97bdeffe7131a167e918f (patch) | |
| tree | f373240719fb57cafbf4f6b2563e90b99364e5b2 | |
| parent | b081436ca4e20c864436bf12a0b0fa4bb82c049a (diff) | |
| download | rust-cf3fcf7758f4e568a5b97bdeffe7131a167e918f.tar.gz rust-cf3fcf7758f4e568a5b97bdeffe7131a167e918f.zip | |
Reuse standard methods
Do not hand-code `Result::ok` or `cmp` in tables.rs.
| -rwxr-xr-x | src/etc/unicode.py | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/src/etc/unicode.py b/src/etc/unicode.py index 5a9fbdd3240..57bb36ce994 100755 --- a/src/etc/unicode.py +++ b/src/etc/unicode.py @@ -319,10 +319,8 @@ def emit_property_module(f, mod, tbl, emit): def emit_conversions_module(f, to_upper, to_lower, to_title): f.write("pub mod conversions {") f.write(""" - 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) { @@ -339,14 +337,7 @@ def emit_conversions_module(f, to_upper, to_lower, to_title): } 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() } """) |
