@@ -261,25 +261,8 @@ mod tests {
261261 input. sort ( ) ;
262262
263263 let map: PatriciaMap < u32 > = input. iter ( ) . cloned ( ) . collect ( ) ;
264- let bytes = postcard:: to_allocvec ( & map) . unwrap ( ) ;
265- let map: PatriciaMap < u32 > = postcard:: from_bytes ( & bytes) . unwrap ( ) ;
266-
267- assert_eq ! ( map. len( ) , 3 ) ;
268- assert_eq ! ( map. into_iter( ) . collect:: <Vec <_>>( ) , input) ;
269- }
270-
271- #[ test]
272- fn serde_json_works ( ) {
273- let mut input = vec ! [
274- ( Vec :: from( "foo" ) , 1u32 ) ,
275- ( "bar" . into( ) , 2 ) ,
276- ( "baz" . into( ) , 3 ) ,
277- ] ;
278- input. sort ( ) ;
279-
280- let map: PatriciaMap < u32 > = input. iter ( ) . cloned ( ) . collect ( ) ;
281- let json = serde_json:: to_string ( & map) . unwrap ( ) ;
282- let map: PatriciaMap < u32 > = serde_json:: from_str ( & json) . unwrap ( ) ;
264+ let serialized = serde_json:: to_vec ( & map) . unwrap ( ) ;
265+ let map: PatriciaMap < u32 > = serde_json:: from_slice ( serialized. as_slice ( ) ) . unwrap ( ) ;
283266
284267 assert_eq ! ( map. len( ) , 3 ) ;
285268 assert_eq ! ( map. into_iter( ) . collect:: <Vec <_>>( ) , input) ;
@@ -293,8 +276,8 @@ mod tests {
293276 input. sort ( ) ;
294277
295278 let map: PatriciaMap < u32 > = input. iter ( ) . cloned ( ) . collect ( ) ;
296- let bytes = postcard :: to_allocvec ( & map) . unwrap ( ) ;
297- let map: PatriciaMap < u32 > = postcard :: from_bytes ( & bytes ) . unwrap ( ) ;
279+ let serialized = serde_json :: to_vec ( & map) . unwrap ( ) ;
280+ let map: PatriciaMap < u32 > = serde_json :: from_slice ( serialized . as_slice ( ) ) . unwrap ( ) ;
298281
299282 assert_eq ! ( map. len( ) , 10000 ) ;
300283 assert_eq ! ( map. into_iter( ) . collect:: <Vec <_>>( ) , input) ;
0 commit comments