diff options
| author | bors <bors@rust-lang.org> | 2014-08-14 05:36:25 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-08-14 05:36:25 +0000 |
| commit | 385c39a77b238df9371ee8bccc768b8d39258edd (patch) | |
| tree | 4d10ee4e9842587cccecdf5a4bf96ef13347362a /src/libunicode/normalize.rs | |
| parent | 9d45d63d0d18f21f74c8a2a4e5367a785932f64e (diff) | |
| parent | fce442e75c5b3df8eea401fae1200314f0d47c40 (diff) | |
| download | rust-385c39a77b238df9371ee8bccc768b8d39258edd.tar.gz rust-385c39a77b238df9371ee8bccc768b8d39258edd.zip | |
auto merge of #16332 : brson/rust/slicestab, r=aturon
This implements some of the recommendations from https://github.com/rust-lang/meeting-minutes/blob/master/Meeting-API-review-2014-08-06.md. Explanation in commits.
Diffstat (limited to 'src/libunicode/normalize.rs')
| -rw-r--r-- | src/libunicode/normalize.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/libunicode/normalize.rs b/src/libunicode/normalize.rs index ec31181e8a7..a60e95c3827 100644 --- a/src/libunicode/normalize.rs +++ b/src/libunicode/normalize.rs @@ -15,20 +15,21 @@ use core::cmp::{Equal, Less, Greater}; use core::option::{Option, Some, None}; -use core::slice::ImmutableVector; +use core::slice; +use core::slice::ImmutableSlice; use tables::normalization::{canonical_table, compatibility_table, composition_table}; fn bsearch_table<T>(c: char, r: &'static [(char, &'static [T])]) -> Option<&'static [T]> { - match r.bsearch(|&(val, _)| { + match r.binary_search(|&(val, _)| { if c == val { Equal } else if val < c { Less } else { Greater } }) { - Some(idx) => { + slice::Found(idx) => { let (_, result) = r[idx]; Some(result) } - None => None + slice::NotFound(_) => None } } @@ -82,16 +83,16 @@ pub fn compose(a: char, b: char) -> Option<char> { match bsearch_table(a, composition_table) { None => None, Some(candidates) => { - match candidates.bsearch(|&(val, _)| { + match candidates.binary_search(|&(val, _)| { if b == val { Equal } else if val < b { Less } else { Greater } }) { - Some(idx) => { + slice::Found(idx) => { let (_, result) = candidates[idx]; Some(result) } - None => None + slice::NotFound(_) => None } } } |
