Skip to content

Commit 0e1ba9b

Browse files
committed
Replace bincode dev-dependency with postcard
Pulls in rust-lang/rust#158077
1 parent 62ae8bd commit 0e1ba9b

4 files changed

Lines changed: 64 additions & 19 deletions

File tree

COMMIT.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cf951bae8758e387dcc2b2480ccd971cd6a15972
1+
fee82a37e9eabf8afe6db62c0177baaf63356a98

Cargo.lock

Lines changed: 55 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ rustc-hash = ["dep:rustc-hash"]
2121
rkyv_0_8 = ["dep:rkyv"]
2222

2323
[dev-dependencies]
24-
bincode = "1.3.3"
24+
postcard = { version = "1", default-features = false, features = ["alloc"] }
2525
serde_json = "1.0"

src/tests.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ fn test_struct_info_roundtrip() {
1313
let de_s = serde_json::from_str(&struct_json).unwrap();
1414
assert_eq!(s, de_s);
1515

16-
// Bincode
17-
let encoded: Vec<u8> = bincode::serialize(&s).unwrap();
18-
let decoded: ItemEnum = bincode::deserialize(&encoded).unwrap();
16+
// Postcard
17+
let encoded: Vec<u8> = postcard::to_allocvec(&s).unwrap();
18+
let decoded: ItemEnum = postcard::from_bytes(&encoded).unwrap();
1919
assert_eq!(s, decoded);
2020
}
2121

@@ -33,9 +33,9 @@ fn test_union_info_roundtrip() {
3333
let de_u = serde_json::from_str(&union_json).unwrap();
3434
assert_eq!(u, de_u);
3535

36-
// Bincode
37-
let encoded: Vec<u8> = bincode::serialize(&u).unwrap();
38-
let decoded: ItemEnum = bincode::deserialize(&encoded).unwrap();
36+
// Postcard
37+
let encoded: Vec<u8> = postcard::to_allocvec(&u).unwrap();
38+
let decoded: ItemEnum = postcard::from_bytes(&encoded).unwrap();
3939
assert_eq!(u, decoded);
4040
}
4141

@@ -59,7 +59,7 @@ mod rkyv {
5959
/// A test to exercise the (de)serialization roundtrip for a representative selection of types,
6060
/// covering most of the rkyv-specific attributes we had to had.
6161
fn test_rkyv_roundtrip() {
62-
// Standard derives: a plain struct and union, mirroring the existing serde/bincode tests.
62+
// Standard derives: a plain struct and union, mirroring the existing serde/postcard tests.
6363
let s = ItemEnum::Struct(Struct {
6464
generics: Generics { params: vec![], where_predicates: vec![] },
6565
kind: StructKind::Plain { fields: vec![Id(1), Id(2)], has_stripped_fields: false },

0 commit comments

Comments
 (0)