9
9
10
10
extern crate string_cache_codegen;
11
11
extern crate phf_codegen;
12
- extern crate rustc_serialize;
12
+ #[ macro_use]
13
+ extern crate serde_derive;
14
+ extern crate serde;
15
+ extern crate serde_json;
13
16
14
- use rustc_serialize:: json:: { Json , Decoder } ;
15
- use rustc_serialize:: Decodable ;
16
17
use std:: collections:: HashMap ;
17
18
#[ allow( unused_imports) ] use std:: ascii:: AsciiExt ;
18
19
use std:: env;
@@ -69,14 +70,14 @@ fn main() {
69
70
70
71
fn named_entities_to_phf ( from : & Path , to : & Path ) {
71
72
// A struct matching the entries in entities.json.
72
- #[ derive( RustcDecodable ) ]
73
+ #[ derive( Deserialize , Debug ) ]
73
74
struct CharRef {
74
75
codepoints : Vec < u32 > ,
75
76
//characters: String, // Present in the file but we don't need it
76
77
}
77
78
78
- let json = Json :: from_reader ( & mut File :: open ( from ) . unwrap ( ) ) . unwrap ( ) ;
79
- let entities : HashMap < String , CharRef > = Decodable :: decode ( & mut Decoder :: new ( json ) ) . unwrap ( ) ;
79
+ let entities : HashMap < String , CharRef >
80
+ = serde_json :: from_reader ( & mut File :: open ( from ) . unwrap ( ) ) . unwrap ( ) ;
80
81
let mut entities: HashMap < & str , ( u32 , u32 ) > = entities. iter ( ) . map ( |( name, char_ref) | {
81
82
assert ! ( name. starts_with( "&" ) ) ;
82
83
assert ! ( char_ref. codepoints. len( ) <= 2 ) ;
@@ -100,4 +101,4 @@ fn named_entities_to_phf(from: &Path, to: &Path) {
100
101
write ! ( & mut file, "pub static NAMED_ENTITIES: Map<&'static str, (u32, u32)> = " ) . unwrap ( ) ;
101
102
phf_map. build ( & mut file) . unwrap ( ) ;
102
103
write ! ( & mut file, ";\n " ) . unwrap ( ) ;
103
- }
104
+ }
0 commit comments