aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2017-07-06 07:34:45 -0700
committerAlex Crichton <alex@alexcrichton.com>2017-07-06 07:34:45 -0700
commitad5bd8758e60fc918423bbbf3dedf04037487d62 (patch)
treec2ac2070b99883d64ee6207839090cc1db4c77c9 /tests
parentf6354998a5083fdda2f34560e7f64b64ecf61f4a (diff)
downloadmilf-rs-ad5bd8758e60fc918423bbbf3dedf04037487d62.tar.gz
milf-rs-ad5bd8758e60fc918423bbbf3dedf04037487d62.zip
Support deserializing newtypes
Closes #196
Diffstat (limited to 'tests')
-rw-r--r--tests/serde.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/serde.rs b/tests/serde.rs
index 2f8d871..3ae2bbd 100644
--- a/tests/serde.rs
+++ b/tests/serde.rs
@@ -509,3 +509,19 @@ fn extra_keys() {
assert!(toml.clone().try_into::<Foo>().is_ok());
assert!(toml::from_str::<Foo>(&toml.to_string()).is_ok());
}
+
+#[test]
+fn newtypes() {
+ #[derive(Deserialize, Serialize, PartialEq, Debug, Clone)]
+ struct A {
+ b: B
+ }
+
+ #[derive(Deserialize, Serialize, PartialEq, Debug, Clone)]
+ struct B(u32);
+
+ equivalent! {
+ A { b: B(2) },
+ Table(map! { b: Integer(2) }),
+ }
+}