Browse Source

stop being dumb about how I fill arrays

pull/3/head
jake 5 years ago
parent
commit
ff8503477b
  1. 11
      psopacket/src/lib.rs

11
psopacket/src/lib.rs

@ -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
},
}
}
};

Loading…
Cancel
Save