Derive Macros§
- Size
OfNo Padding - Create a shadow struct which as same as original struct except it’s marked
#[repr(packed)]. callsize_of_no_padding()method on struct will invokestd::mem::size_of()function on shadow one in compile time. - Size
OfNo Padding Any - Calculate the size for every field, add up all the size. call
size_of_no_padding_any(&self)will give the size of whole struct without padding in runtime.