Skip to content
Myr

Merge pull request #3037 from dishmaker/dishmaker/serde_derive_ast_iter_enumerate

Before adoption: this commit came in with the history the project adopted, so no landing records it.

serde_derive: rewrite fields_from_ast with less llvm-lines

authored by David Tolnay · committed by GitHub · parents 7893347, 1229fc8 · Browse files · 1 file+15 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+15 added−8 removed

  • other:+15 added−8 removed

1 file+15 added−8 removed

modified:serde_derive/src/internals/ast.rs+15 added-8 removed
200 unmodified lines
201 attrs: Option<&attr::Variant>,202 container_default: &attr::Default,203 private: &Ident,204) -> Vec<Field<'a>> {205 fields206 .iter()207 .enumerate()208 .map(|(i, field)| Field {205 let mut dst_fields = Vec::with_capacity(fields.len());206 for field in fields {207 dst_fields.push(Field {208 member: match &field.ident {209 Some(ident) => syn::Member::Named(ident.clone()),211 None => syn::Member::Unnamed(i.into()),210 None => syn::Member::Unnamed(dst_fields.len().into()),211 },213 attrs: attr::Field::from_ast(cx, i, field, attrs, container_default, private),212 attrs: attr::Field::from_ast(213 cx,214 dst_fields.len(),215 field,216 attrs,217 container_default,218 private,219 ),220 ty: &field.ty,221 original: field,216 })217 .collect()222 });223 }224 dst_fields225}