Skip to content

Commit cf3fcf7

Browse files
committed
Reuse standard methods
Do not hand-code `Result::ok` or `cmp` in tables.rs.
1 parent b081436 commit cf3fcf7

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

src/etc/unicode.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,8 @@ def emit_property_module(f, mod, tbl, emit):
319319
def emit_conversions_module(f, to_upper, to_lower, to_title):
320320
f.write("pub mod conversions {")
321321
f.write("""
322-
use core::cmp::Ordering::{Equal, Less, Greater};
323322
use core::option::Option;
324323
use core::option::Option::{Some, None};
325-
use core::result::Result::{Ok, Err};
326324
327325
pub fn to_lower(c: char) -> [char; 3] {
328326
match bsearch_case_table(c, to_lowercase_table) {
@@ -339,14 +337,7 @@ def emit_conversions_module(f, to_upper, to_lower, to_title):
339337
}
340338
341339
fn bsearch_case_table(c: char, table: &'static [(char, [char; 3])]) -> Option<usize> {
342-
match table.binary_search_by(|&(key, _)| {
343-
if c == key { Equal }
344-
else if key < c { Less }
345-
else { Greater }
346-
}) {
347-
Ok(i) => Some(i),
348-
Err(_) => None,
349-
}
340+
table.binary_search_by(|&(key, _)| key.cmp(&c)).ok()
350341
}
351342
352343
""")

0 commit comments

Comments
 (0)