diff --git a/psopacket/src/lib.rs b/psopacket/src/lib.rs index 8dd1acc..4207dc6 100644 --- a/psopacket/src/lib.rs +++ b/psopacket/src/lib.rs @@ -92,11 +92,14 @@ fn generate_psopacket_impl(pkt_cmd: u16, name: syn::Ident, attrs: &Vec } }, AttrType::Array(ty, name, len, _) => { - let array_init = (0..*len).map(|_k| quote! { - #ty::from_bytes(&mut cur)?, - }); quote! { - #name: [#(#array_init)*], + #name: { + let mut arr = [#ty::default(); #len]; + for e in arr.iter_mut() { + *e = #ty::from_bytes(&mut cur)? + } + arr + }, } } };