77// option. This file may not be copied, modified, or distributed
88// except according to those terms.
99
10- #![ feature( rustc_encodable_decodable) ]
11-
1210extern crate phf_codegen;
13- extern crate rustc_serialize;
1411
15- use rustc_serialize:: json:: { Json , Decoder } ;
16- use rustc_serialize:: Decodable ;
1712use std:: collections:: HashMap ;
1813use std:: env;
1914use std:: fs:: File ;
@@ -99,14 +94,13 @@ fn check_hash(from: &Path, to: &Path) -> Result<(), String> {
9994
10095fn named_entities_to_phf ( from : & Path , to : & Path ) {
10196 // A struct matching the entries in entities.json.
102- #[ derive( RustcDecodable ) ]
97+ #[ derive( serde :: Deserialize ) ]
10398 struct CharRef {
10499 codepoints : Vec < u32 > ,
105100 //characters: String, // Present in the file but we don't need it
106101 }
107102
108- let json = Json :: from_reader ( & mut File :: open ( from) . unwrap ( ) ) . unwrap ( ) ;
109- let entities: HashMap < String , CharRef > = Decodable :: decode ( & mut Decoder :: new ( json) ) . unwrap ( ) ;
103+ let entities: HashMap < String , CharRef > = serde_json:: from_reader ( & mut File :: open ( from) . unwrap ( ) ) . unwrap ( ) ;
110104 let mut entities: HashMap < & str , ( u32 , u32 ) > = entities. iter ( ) . map ( |( name, char_ref) | {
111105 assert ! ( name. starts_with( "&" ) ) ;
112106 assert ! ( char_ref. codepoints. len( ) <= 2 ) ;
@@ -115,7 +109,7 @@ fn named_entities_to_phf(from: &Path, to: &Path) {
115109
116110 // Add every missing prefix of those keys, mapping to NULL characters.
117111 for key in entities. keys ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) {
118- for n in 1 .. key. len ( ) {
112+ for n in 1 .. key. len ( ) {
119113 entities. entry ( & key[ ..n] ) . or_insert ( ( 0 , 0 ) ) ;
120114 }
121115 }
0 commit comments