Skip to content

Commit

Permalink
Use if instead of match
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingun committed Jul 11, 2023
1 parent 2bc1f8d commit 4cb63f2
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions serde_derive/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1008,29 +1008,28 @@ fn deserialize_struct(

// untagged struct variants do not get a visit_seq method. The same applies to
// structs that only have a map representation.
let visit_seq = match form {
_ if cattrs.has_flatten() => None,
_ => {
let mut_seq = if field_names_idents.is_empty() {
quote!(_)
} else {
quote!(mut __seq)
};
let visit_seq = if cattrs.has_flatten() {
None
} else {
let mut_seq = if field_names_idents.is_empty() {
quote!(_)
} else {
quote!(mut __seq)
};

let visit_seq = Stmts(deserialize_seq(
&type_path, params, fields, true, cattrs, expecting,
));
let visit_seq = Stmts(deserialize_seq(
&type_path, params, fields, true, cattrs, expecting,
));

Some(quote! {
#[inline]
fn visit_seq<__A>(self, #mut_seq: __A) -> _serde::__private::Result<Self::Value, __A::Error>
where
__A: _serde::de::SeqAccess<#delife>,
{
#visit_seq
}
})
}
Some(quote! {
#[inline]
fn visit_seq<__A>(self, #mut_seq: __A) -> _serde::__private::Result<Self::Value, __A::Error>
where
__A: _serde::de::SeqAccess<#delife>,
{
#visit_seq
}
})
};
let visit_map = Stmts(deserialize_map(&type_path, params, fields, cattrs));

Expand Down

0 comments on commit 4cb63f2

Please sign in to comment.