From 95d419ba990920dfdc30b7b88d6df1c0d2d5737f Mon Sep 17 00:00:00 2001 From: James Kay Date: Thu, 5 Sep 2019 15:18:26 +0100 Subject: Nested dotted-table enums (#329) Add support for deserializing enums from nested dotted tables. --- tests/enum_external_deserialize.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') diff --git a/tests/enum_external_deserialize.rs b/tests/enum_external_deserialize.rs index 3c38580..6d45b48 100644 --- a/tests/enum_external_deserialize.rs +++ b/tests/enum_external_deserialize.rs @@ -2,6 +2,11 @@ extern crate serde_derive; extern crate toml; +#[derive(Debug, Deserialize, PartialEq)] +struct OuterStruct { + inner: TheEnum, +} + #[derive(Debug, Deserialize, PartialEq)] enum TheEnum { Plain, @@ -181,6 +186,21 @@ mod enum_struct { .unwrap() ); } + + #[test] + fn from_nested_dotted_table() { + assert_eq!( + OuterStruct { + inner: TheEnum::Struct { value: -123 } + }, + toml::from_str( + r#"[inner.Struct] + value = -123 + "# + ) + .unwrap() + ); + } } mod enum_array { -- cgit v1.2.3