diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2022-09-03 21:23:44 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2022-09-03 21:25:55 -0300 |
commit | 19340aea20881674d8d87d63101da19983c64479 (patch) | |
tree | 827a8e173237e39a504a7f68b23c6d577c8483e5 /tests |
[Project] Serde Transmute
Transmute objects through Serde! This crate allows converting a value which can be serialized into a type which can be deserialized.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/foobar.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/foobar.rs b/tests/foobar.rs new file mode 100644 index 0000000..8495ccb --- /dev/null +++ b/tests/foobar.rs @@ -0,0 +1,18 @@ + +#[derive(serde::Serialize)] +struct Foo { + s: String, +} + +#[derive(serde::Deserialize)] +struct Bar { + s: String, +} + +#[test] +fn transmute() { + let settings = Default::default(); + let foo = Foo { s: String::from("Hello!") }; + let bar: Bar = serde_transmute::transmute(&foo, &settings).unwrap(); + assert_eq!(foo.s, bar.s); +} |