File tree Expand file tree Collapse file tree 2 files changed +40
-2
lines changed Expand file tree Collapse file tree 2 files changed +40
-2
lines changed Original file line number Diff line number Diff line change 1- use std:: collections:: HashMap ;
1+ use std:: collections:: BTreeMap ;
2+ use std:: fs:: File ;
3+ use std:: io:: Write ;
4+ use std:: path:: Path ;
25
36const DATA : & str = include_str ! ( "vendor/detect-writing-script/data.json" ) ;
47
8+ macro_rules! ok(
9+ ( $result: expr) => ( $result. unwrap( ) ) ;
10+ ) ;
11+
512fn main ( ) {
6- let _: HashMap < String , Vec < [ usize ; 2 ] > > = serde_json:: from_str ( DATA ) . unwrap ( ) ;
13+ let data: BTreeMap < String , Vec < [ u32 ; 2 ] > > = ok ! ( serde_json:: from_str( DATA ) ) ;
14+ let script_count = data. len ( ) ;
15+
16+ let root = ok ! ( std:: env:: var( "OUT_DIR" ) ) ;
17+ let path = Path :: new ( & root) . join ( "data.rs" ) ;
18+ let mut file = ok ! ( File :: create( & path) ) ;
19+ ok ! ( write!(
20+ file,
21+ r#"
22+ const SCRIPT_COUNT: usize = {script_count};
23+ "# ,
24+ ) ) ;
725}
Original file line number Diff line number Diff line change 11//! Detection of writing scripts from Unicode codepoints.
2+
3+ include ! ( concat!( env!( "OUT_DIR" ) , "/data.rs" ) ) ;
4+
5+ /// A match.
6+ #[ derive( Clone , Copy ) ]
7+ pub struct Match {
8+ pub name : & ' static str ,
9+ pub count : usize ,
10+ pub score : f64 ,
11+ }
12+
13+ /// Detect writing scripts given ranges of Unicode codepoints.
14+ pub fn detect < T > ( _codepoints : T , _threshold : f64 ) -> Vec < Match >
15+ where
16+ T : IntoIterator < Item = [ u32 ; 2 ] > ,
17+ {
18+ let _ = [ 0 ; SCRIPT_COUNT ] ;
19+
20+ unimplemented ! ( )
21+ }
You can’t perform that action at this time.
0 commit comments