Simplify access of packed struct fields in derived Serialize impls

This commit is contained in:
David Tolnay 2020-05-09 22:53:30 -07:00
parent c2114491ca
commit 1fe39043ee
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -1246,14 +1246,14 @@ fn get_member(params: &Parameters, field: &Field, member: &Member) -> TokenStrea
match (params.is_remote, field.attrs.getter()) { match (params.is_remote, field.attrs.getter()) {
(false, None) => { (false, None) => {
if params.is_packed { if params.is_packed {
quote!(&{let copy = #self_var.#member; copy }) quote!(&{#self_var.#member})
} else { } else {
quote!(&#self_var.#member) quote!(&#self_var.#member)
} }
} }
(true, None) => { (true, None) => {
let inner = if params.is_packed { let inner = if params.is_packed {
quote!(&{let copy = #self_var.#member; copy }) quote!(&{#self_var.#member})
} else { } else {
quote!(&#self_var.#member) quote!(&#self_var.#member)
}; };