stop being dumb about how I fill arrays
This commit is contained in:
parent
ea488cadca
commit
ff8503477b
@ -92,11 +92,14 @@ fn generate_psopacket_impl(pkt_cmd: u16, name: syn::Ident, attrs: &Vec<AttrType>
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
AttrType::Array(ty, name, len, _) => {
|
AttrType::Array(ty, name, len, _) => {
|
||||||
let array_init = (0..*len).map(|_k| quote! {
|
|
||||||
#ty::from_bytes(&mut cur)?,
|
|
||||||
});
|
|
||||||
quote! {
|
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…
x
Reference in New Issue
Block a user