mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-11 20:51:04 +00:00
Merge branch serde-rs/master into Gankro/deserialize_from
This commit is contained in:
@@ -723,7 +723,13 @@ pub enum Default {
|
||||
|
||||
impl Field {
|
||||
/// Extract out the `#[serde(...)]` attributes from a struct field.
|
||||
pub fn from_ast(cx: &Ctxt, index: usize, field: &syn::Field, attrs: Option<&Variant>) -> Self {
|
||||
pub fn from_ast(
|
||||
cx: &Ctxt,
|
||||
index: usize,
|
||||
field: &syn::Field,
|
||||
attrs: Option<&Variant>,
|
||||
container_default: &Default,
|
||||
) -> Self {
|
||||
let mut ser_name = Attr::none(cx, "rename");
|
||||
let mut de_name = Attr::none(cx, "rename");
|
||||
let mut skip_serializing = BoolAttr::none(cx, "skip_serializing");
|
||||
@@ -890,9 +896,10 @@ impl Field {
|
||||
}
|
||||
}
|
||||
|
||||
// Is skip_deserializing, initialize the field to Default::default()
|
||||
// unless a different default is specified by `#[serde(default = "...")]`
|
||||
if skip_deserializing.0.value.is_some() {
|
||||
// Is skip_deserializing, initialize the field to Default::default() unless a different
|
||||
// default is specified by `#[serde(default = "...")]` on ourselves or our container (e.g.
|
||||
// the struct we are in).
|
||||
if container_default == &Default::None && skip_deserializing.0.value.is_some() {
|
||||
default.set_if_none(Default::Default);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user