@@ -290,11 +290,11 @@ def emit_bsearch_range_table(f):
290290fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
291291 use core::cmp::Ordering::{Equal, Less, Greater};
292292 use core::slice::SliceExt;
293- r.binary_search (|&(lo,hi)| {
293+ r.binary_search_by (|&(lo,hi)| {
294294 if lo <= c && c <= hi { Equal }
295295 else if hi < c { Less }
296296 else { Greater }
297- }).found().is_some ()
297+ }).is_ok ()
298298}\n
299299""" )
300300
@@ -303,7 +303,7 @@ def emit_table(f, name, t_data, t_type = "&'static [(char, char)]", is_pub=True,
303303 pub_string = ""
304304 if is_pub :
305305 pub_string = "pub "
306- f .write (" %sstatic %s: %s = &[\n " % (pub_string , name , t_type ))
306+ f .write (" %sconst %s: %s = &[\n " % (pub_string , name , t_type ))
307307 data = ""
308308 first = True
309309 for dat in t_data :
@@ -329,14 +329,14 @@ def emit_property_module(f, mod, tbl, emit_fn):
329329def emit_regex_module (f , cats , w_data ):
330330 f .write ("pub mod regex {\n " )
331331 regex_class = "&'static [(char, char)]"
332- class_table = "&'static [(&'static str, &'static %s)]" % regex_class
332+ class_table = "&'static [(&'static str, %s)]" % regex_class
333333
334334 emit_table (f , "UNICODE_CLASSES" , cats , class_table ,
335- pfun = lambda x : "(\" %s\" ,& super::%s::%s_table)" % (x [0 ], x [1 ], x [0 ]))
335+ pfun = lambda x : "(\" %s\" ,super::%s::%s_table)" % (x [0 ], x [1 ], x [0 ]))
336336
337- f .write (" pub static PERLD: &'static %s = & super::general_category::Nd_table;\n \n "
337+ f .write (" pub const PERLD: %s = super::general_category::Nd_table;\n \n "
338338 % regex_class )
339- f .write (" pub static PERLS: &'static %s = & super::property::White_Space_table;\n \n "
339+ f .write (" pub const PERLS: %s = super::property::White_Space_table;\n \n "
340340 % regex_class )
341341
342342 emit_table (f , "PERLW" , w_data , regex_class )
@@ -350,7 +350,7 @@ def emit_conversions_module(f, lowerupper, upperlower):
350350 use core::slice::SliceExt;
351351 use core::option::Option;
352352 use core::option::Option::{Some, None};
353- use core::slice ;
353+ use core::result::Result::{Ok, Err} ;
354354
355355 pub fn to_lower(c: char) -> char {
356356 match bsearch_case_table(c, LuLl_table) {
@@ -367,13 +367,13 @@ def emit_conversions_module(f, lowerupper, upperlower):
367367 }
368368
369369 fn bsearch_case_table(c: char, table: &'static [(char, char)]) -> Option<usize> {
370- match table.binary_search (|&(key, _)| {
370+ match table.binary_search_by (|&(key, _)| {
371371 if c == key { Equal }
372372 else if key < c { Less }
373373 else { Greater }
374374 }) {
375- slice::BinarySearchResult::Found (i) => Some(i),
376- slice::BinarySearchResult::NotFound (_) => None,
375+ Ok (i) => Some(i),
376+ Err (_) => None,
377377 }
378378 }
379379
@@ -386,10 +386,9 @@ def emit_conversions_module(f, lowerupper, upperlower):
386386
387387def emit_grapheme_module (f , grapheme_table , grapheme_cats ):
388388 f .write ("""pub mod grapheme {
389- use core::kinds::Copy;
390389 use core::slice::SliceExt;
391390 pub use self::GraphemeCat::*;
392- use core::slice ;
391+ use core::result::Result::{Ok, Err} ;
393392
394393 #[allow(non_camel_case_types)]
395394 #[derive(Clone, Copy)]
@@ -401,16 +400,16 @@ def emit_grapheme_module(f, grapheme_table, grapheme_cats):
401400
402401 fn bsearch_range_value_table(c: char, r: &'static [(char, char, GraphemeCat)]) -> GraphemeCat {
403402 use core::cmp::Ordering::{Equal, Less, Greater};
404- match r.binary_search (|&(lo, hi, _)| {
403+ match r.binary_search_by (|&(lo, hi, _)| {
405404 if lo <= c && c <= hi { Equal }
406405 else if hi < c { Less }
407406 else { Greater }
408407 }) {
409- slice::BinarySearchResult::Found (idx) => {
408+ Ok (idx) => {
410409 let (_, _, cat) = r[idx];
411410 cat
412411 }
413- slice::BinarySearchResult::NotFound (_) => GC_Any
412+ Err (_) => GC_Any
414413 }
415414 }
416415
@@ -430,20 +429,20 @@ def emit_charwidth_module(f, width_table):
430429 f .write (" use core::option::Option;\n " )
431430 f .write (" use core::option::Option::{Some, None};\n " )
432431 f .write (" use core::slice::SliceExt;\n " )
433- f .write (" use core::slice ;\n " )
432+ f .write (" use core::result::Result::{Ok, Err} ;\n " )
434433 f .write ("""
435434 fn bsearch_range_value_table(c: char, is_cjk: bool, r: &'static [(char, char, u8, u8)]) -> u8 {
436435 use core::cmp::Ordering::{Equal, Less, Greater};
437- match r.binary_search (|&(lo, hi, _, _)| {
436+ match r.binary_search_by (|&(lo, hi, _, _)| {
438437 if lo <= c && c <= hi { Equal }
439438 else if hi < c { Less }
440439 else { Greater }
441440 }) {
442- slice::BinarySearchResult::Found (idx) => {
441+ Ok (idx) => {
443442 let (_, _, r_ncjk, r_cjk) = r[idx];
444443 if is_cjk { r_cjk } else { r_ncjk }
445444 }
446- slice::BinarySearchResult::NotFound (_) => 1
445+ Err (_) => 1
447446 }
448447 }
449448""" )
@@ -530,17 +529,17 @@ def comp_pfun(char):
530529 fn bsearch_range_value_table(c: char, r: &'static [(char, char, u8)]) -> u8 {
531530 use core::cmp::Ordering::{Equal, Less, Greater};
532531 use core::slice::SliceExt;
533- use core::slice ;
534- match r.binary_search (|&(lo, hi, _)| {
532+ use core::result::Result::{Ok, Err} ;
533+ match r.binary_search_by (|&(lo, hi, _)| {
535534 if lo <= c && c <= hi { Equal }
536535 else if hi < c { Less }
537536 else { Greater }
538537 }) {
539- slice::BinarySearchResult::Found (idx) => {
538+ Ok (idx) => {
540539 let (_, _, result) = r[idx];
541540 result
542541 }
543- slice::BinarySearchResult::NotFound (_) => 0
542+ Err (_) => 0
544543 }
545544 }\n
546545""" )
@@ -609,7 +608,7 @@ def optimize_width_table(wtable):
609608 unicode_version = re .search (pattern , readme .read ()).groups ()
610609 rf .write ("""
611610/// The version of [Unicode](http://www.unicode.org/)
612- /// that the `UnicodeChar ` and `UnicodeStrPrelude` traits are based on.
611+ /// that the unicode parts of `CharExt ` and `UnicodeStrPrelude` traits are based on.
613612pub const UNICODE_VERSION: (u64, u64, u64) = (%s, %s, %s);
614613""" % unicode_version )
615614 (canon_decomp , compat_decomp , gencats , combines ,
0 commit comments