File tree 3 files changed +23
-4
lines changed
3 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -246,6 +246,15 @@ dependencies = [
246
246
" serde" ,
247
247
]
248
248
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
+
249
258
[[package ]]
250
259
name = " bitflags"
251
260
version = " 1.3.2"
@@ -4351,6 +4360,7 @@ dependencies = [
4351
4360
name = " rustdoc-json-types"
4352
4361
version = " 0.1.0"
4353
4362
dependencies = [
4363
+ " bincode" ,
4354
4364
" rustc-hash" ,
4355
4365
" serde" ,
4356
4366
" serde_json" ,
Original file line number Diff line number Diff line change @@ -12,3 +12,4 @@ rustc-hash = "1.1.0"
12
12
13
13
[dev-dependencies ]
14
14
serde_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() {
8
8
impls : vec ! [ ] ,
9
9
} ) ;
10
10
11
+ // JSON
11
12
let struct_json = serde_json:: to_string ( & s) . unwrap ( ) ;
12
-
13
13
let de_s = serde_json:: from_str ( & struct_json) . unwrap ( ) ;
14
-
15
14
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) ;
16
20
}
17
21
18
22
#[ test]
@@ -24,9 +28,13 @@ fn test_union_info_roundtrip() {
24
28
impls : vec ! [ ] ,
25
29
} ) ;
26
30
31
+ // JSON
27
32
let union_json = serde_json:: to_string ( & u) . unwrap ( ) ;
28
-
29
33
let de_u = serde_json:: from_str ( & union_json) . unwrap ( ) ;
30
-
31
34
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) ;
32
40
}
You can’t perform that action at this time.
0 commit comments