From 858d6d3227aae92cd740296588209d5097c9a63c Mon Sep 17 00:00:00 2001 From: Victor Koenders Date: Thu, 30 Mar 2023 11:45:23 +0200 Subject: [PATCH] Made arrays with 32 elements or less never encode their length --- compatibility/src/lib.rs | 12 ++++++++---- compatibility/src/misc.rs | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/compatibility/src/lib.rs b/compatibility/src/lib.rs index 96fde3f5..05d4dbe2 100644 --- a/compatibility/src/lib.rs +++ b/compatibility/src/lib.rs @@ -22,18 +22,22 @@ where // This is what bincode 1 serializes to. This will be our comparison value. let encoded = bincode_1_options.serialize(t).unwrap(); - println!("Encoded {:?} as {:?}", t, encoded); + println!("Encoded {t:?} as {encoded:?}"); // Test bincode 2 encode let bincode_2_output = bincode_2::encode_to_vec(t, bincode_2_config).unwrap(); - assert_eq!(encoded, bincode_2_output, "{:?} serializes differently", t); + assert_eq!( + encoded, + bincode_2_output, + "{t:?} serializes differently\nbincode 2 config {:?}", + core::any::type_name::(), + ); // Test bincode 2 serde serialize let bincode_2_serde_output = bincode_2::serde::encode_to_vec(t, bincode_2_config).unwrap(); assert_eq!( encoded, bincode_2_serde_output, - "{:?} serializes differently", - t + "{t:?} serializes differently" ); // Test bincode 1 deserialize diff --git a/compatibility/src/misc.rs b/compatibility/src/misc.rs index 2ab756d4..52760697 100644 --- a/compatibility/src/misc.rs +++ b/compatibility/src/misc.rs @@ -2,6 +2,7 @@ fn test() { super::test_same((1,)); super::test_same(TupleS(2.0, 3.0, 4.0)); + super::test_same([2.0, 3.0, 4.0]); super::test_same(Option::::Some(5)); super::test_same(Option::::None); super::test_same(Result::::Ok(5));