When a field should be skipped during deserialization, it will not use its own Default implementation
when the container structure has `#[serde(default)]` set.
This commit is contained in:
Jeroen Bollen
2017-12-06 21:07:16 +01:00
parent 0c34e06e51
commit c887a0b472
4 changed files with 93 additions and 26 deletions
+23
View File
@@ -447,7 +447,30 @@ fn deserialize_seq(
};
}
let let_default = match *cattrs.default() {
attr::Default::Default => {
Some(
quote!(
let __default: Self::Value = _serde::export::Default::default();
),
)
}
attr::Default::Path(ref path) => {
Some(
quote!(
let __default: Self::Value = #path();
),
)
}
attr::Default::None => {
// We don't need the default value, to prevent an unused variable warning
// we'll leave the line empty.
None
}
};
quote_block! {
#let_default
#(#let_values)*
_serde::export::Ok(#result)
}