diff --git a/yaserde/tests/default.rs b/yaserde/tests/default.rs
index c4ba308..5fadd15 100644
--- a/yaserde/tests/default.rs
+++ b/yaserde/tests/default.rs
@@ -110,3 +110,32 @@ fn default_attribute_string() {
serialize_and_validate!(model, content);
deserialize_and_validate!(content, model, XmlStruct);
}
+
+#[test]
+fn module_inclusion() {
+ mod module {
+ use super::*;
+
+ #[derive(Debug, Default, PartialEq, YaDeserialize, YaSerialize)]
+ #[yaserde(rename = "module")]
+ pub struct Module {
+ #[yaserde(attribute)]
+ pub color: String,
+ }
+ }
+
+ #[derive(Debug, PartialEq, YaDeserialize, YaSerialize)]
+ #[yaserde(rename = "base")]
+ pub struct XmlStruct {
+ background: module::Module,
+ }
+
+ let content = r#""#;
+ let model = XmlStruct {
+ background: module::Module {
+ color: "blue".to_string(),
+ },
+ };
+ serialize_and_validate!(model, content);
+ deserialize_and_validate!(content, model, XmlStruct);
+}
diff --git a/yaserde_derive/src/common/field.rs b/yaserde_derive/src/common/field.rs
index 1c9125e..35ecc79 100644
--- a/yaserde_derive/src/common/field.rs
+++ b/yaserde_derive/src/common/field.rs
@@ -225,7 +225,11 @@ impl From<&syn::Path> for Field {
impl From<&syn::Field> for Field {
fn from(field: &syn::Field) -> Self {
- match field.ty {
+ let mut ty = &field.ty;
+ while let syn::Type::Group(g) = ty {
+ ty = &g.elem;
+ }
+ match ty {
Path(ref path) => Field::from(&path.path),
_ => panic!("unable to match {:?}", field.ty),
}