-
-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix tuple struct encoding in serde (#549)
- Loading branch information
Showing
7 changed files
with
96 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
#[test] | ||
fn test() { | ||
super::test_same((1,)); | ||
super::test_same(TupleS(2.0, 3.0, 4.0)); | ||
super::test_same(Option::<u32>::Some(5)); | ||
super::test_same(Option::<u32>::None); | ||
super::test_same(Result::<u32, u8>::Ok(5)); | ||
super::test_same(Result::<u32, u8>::Err(5)); | ||
super::test_same(std::net::Ipv4Addr::LOCALHOST); | ||
super::test_same(std::net::Ipv6Addr::LOCALHOST); | ||
} | ||
|
||
#[derive( | ||
bincode_2::Encode, bincode_2::Decode, serde::Serialize, serde::Deserialize, Debug, PartialEq, | ||
)] | ||
#[bincode(crate = "bincode_2")] | ||
struct TupleS(f32, f32, f32); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,6 @@ mod issue_500; | |
|
||
#[path = "issues/issue_523.rs"] | ||
mod issue_523; | ||
|
||
#[path = "issues/issue_547.rs"] | ||
mod issue_547; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#![cfg(all(feature = "serde", feature = "std"))] | ||
|
||
use glam::vec3; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Serialize, Deserialize, Debug, PartialEq)] | ||
struct Instance { | ||
position: glam::Vec3, | ||
} | ||
|
||
#[test] | ||
fn test() { | ||
let instance = Instance { | ||
position: vec3(2.0, 2.0, 2.0), | ||
}; | ||
|
||
let m = bincode::serde::encode_to_vec(&instance, bincode::config::standard()).unwrap(); | ||
let instance2: Instance = bincode::serde::decode_from_slice(&m, bincode::config::standard()) | ||
.unwrap() | ||
.0; | ||
|
||
assert_eq!(instance, instance2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters