stop being dumb about how I fill arrays

This commit is contained in:
jake 2019-10-26 16:11:21 -07:00
parent ea488cadca
commit ff8503477b

View File

@ -92,11 +92,14 @@ fn generate_psopacket_impl(pkt_cmd: u16, name: syn::Ident, attrs: &Vec<AttrType>
}
},
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
},
}
}
};