Actually, field_names_idents
can be calculated using the same code in both cases
When !cattrs.has_flatten() all fields is !field.attrs.flatten() Co-authored-by: Oliver Schneider <oli-obk@users.noreply.github.com>
This commit is contained in:
parent
75db73066b
commit
5ffebeb6ef
@ -940,37 +940,25 @@ fn deserialize_struct(
|
|||||||
};
|
};
|
||||||
let expecting = cattrs.expecting().unwrap_or(&expecting);
|
let expecting = cattrs.expecting().unwrap_or(&expecting);
|
||||||
|
|
||||||
|
let field_names_idents: Vec<_> = fields
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
// Skip fields that shouldn't be deserialized or that were flattened,
|
||||||
|
// so they don't appear in the storage in their literal form
|
||||||
|
.filter(|&(_, field)| !field.attrs.skip_deserializing() && !field.attrs.flatten())
|
||||||
|
.map(|(i, field)| {
|
||||||
|
(
|
||||||
|
field.attrs.name().deserialize_name(),
|
||||||
|
field_i(i),
|
||||||
|
field.attrs.aliases(),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
let (field_visitor, fields_stmt) = if cattrs.has_flatten() {
|
let (field_visitor, fields_stmt) = if cattrs.has_flatten() {
|
||||||
let field_names_idents: Vec<_> = fields
|
|
||||||
.iter()
|
|
||||||
.enumerate()
|
|
||||||
.filter(|&(_, field)| !field.attrs.skip_deserializing() && !field.attrs.flatten())
|
|
||||||
.map(|(i, field)| {
|
|
||||||
(
|
|
||||||
field.attrs.name().deserialize_name(),
|
|
||||||
field_i(i),
|
|
||||||
field.attrs.aliases(),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let field_visitor = deserialize_generated_identifier(&field_names_idents, cattrs, false, None);
|
let field_visitor = deserialize_generated_identifier(&field_names_idents, cattrs, false, None);
|
||||||
|
|
||||||
(field_visitor, None)
|
(field_visitor, None)
|
||||||
} else {
|
} else {
|
||||||
let field_names_idents: Vec<_> = fields
|
|
||||||
.iter()
|
|
||||||
.enumerate()
|
|
||||||
.filter(|&(_, field)| !field.attrs.skip_deserializing())
|
|
||||||
.map(|(i, field)| {
|
|
||||||
(
|
|
||||||
field.attrs.name().deserialize_name(),
|
|
||||||
field_i(i),
|
|
||||||
field.attrs.aliases(),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let fields_stmt = {
|
let fields_stmt = {
|
||||||
let field_names = field_names_idents
|
let field_names = field_names_idents
|
||||||
.iter()
|
.iter()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user