mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-26 16:47:54 +00:00
Solved #1105.
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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user