File tree Expand file tree Collapse file tree 3 files changed +23
-4
lines changed Expand file tree Collapse file tree 3 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -246,6 +246,15 @@ dependencies = [
246246 " serde" ,
247247]
248248
249+ [[package ]]
250+ name = " bincode"
251+ version = " 1.3.3"
252+ source = " registry+https://github.com/rust-lang/crates.io-index"
253+ checksum = " b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
254+ dependencies = [
255+ " serde" ,
256+ ]
257+
249258[[package ]]
250259name = " bitflags"
251260version = " 1.3.2"
@@ -4351,6 +4360,7 @@ dependencies = [
43514360name = " rustdoc-json-types"
43524361version = " 0.1.0"
43534362dependencies = [
4363+ " bincode" ,
43544364 " rustc-hash" ,
43554365 " serde" ,
43564366 " serde_json" ,
Original file line number Diff line number Diff line change @@ -12,3 +12,4 @@ rustc-hash = "1.1.0"
1212
1313[dev-dependencies ]
1414serde_json = " 1.0"
15+ bincode = " 1"
Original file line number Diff line number Diff line change @@ -8,11 +8,15 @@ fn test_struct_info_roundtrip() {
88 impls : vec ! [ ] ,
99 } ) ;
1010
11+ // JSON
1112 let struct_json = serde_json:: to_string ( & s) . unwrap ( ) ;
12-
1313 let de_s = serde_json:: from_str ( & struct_json) . unwrap ( ) ;
14-
1514 assert_eq ! ( s, de_s) ;
15+
16+ // Bincode
17+ let encoded: Vec < u8 > = bincode:: serialize ( & s) . unwrap ( ) ;
18+ let decoded: ItemEnum = bincode:: deserialize ( & encoded) . unwrap ( ) ;
19+ assert_eq ! ( s, decoded) ;
1620}
1721
1822#[ test]
@@ -24,9 +28,13 @@ fn test_union_info_roundtrip() {
2428 impls : vec ! [ ] ,
2529 } ) ;
2630
31+ // JSON
2732 let union_json = serde_json:: to_string ( & u) . unwrap ( ) ;
28-
2933 let de_u = serde_json:: from_str ( & union_json) . unwrap ( ) ;
30-
3134 assert_eq ! ( u, de_u) ;
35+
36+ // Bincode
37+ let encoded: Vec < u8 > = bincode:: serialize ( & u) . unwrap ( ) ;
38+ let decoded: ItemEnum = bincode:: deserialize ( & encoded) . unwrap ( ) ;
39+ assert_eq ! ( u, decoded) ;
3240}
You can’t perform that action at this time.
0 commit comments