Hello,
I want to create an byte array whose size equal some struct size , for example :
use std::mem;
struct Foo {
a: i64,
}
fn main () {
let arr: [u8; mem::size_of::()] = unsafe { mem::zeroed() };
}
Above code does not work. Any idea how to create such array from rust lang only.
Is it possible to compute the structure size at compile time (using compiler plugin or macros) like this
let arr: [u8; sizeof!(Foo)] ;
Thanks
Ajay.