struct_padding

Macro struct_padding 

Source
macro_rules! struct_padding {
    ($t:ty, [$($ts:ty),*]) => { ... };
}
Expand description

How many padding bytes does the struct type $t have?

$ts is the list of the type of every field in $t. $t must be a struct type, or else struct_padding!’s result may be meaningless.

Note that struct_padding!’s results are independent of repcr since they only consider the size of the type and the sizes of the fields. Whatever the repr, the size of the type already takes into account any padding that the compiler has decided to add. Structs with well-defined representations (such as repr(C)) can use this macro to check for padding. Note that while this may yield some consistent value for some repr(Rust) structs, it is not guaranteed across platforms or compilations.