macro_rules! enum_padding {
($t:ty, $disc:ty, $([$($ts:ty),*]),*) => { ... };
}Expand description
How many padding bytes does the enum type $t have?
$disc is the type of the enum tag, and $ts is a list of fields in each
square-bracket-delimited variant. $t must be an enum, or else
enum_padding!’s result may be meaningless. An enum has padding if any of
its variant structs 1 contain padding, and so all of the variants of an
enum must be “full” in order for the enum to not have padding.
The results of enum_padding! require that the enum is not repr(Rust), as
repr(Rust) enums may niche the enum’s tag and reduce the total number of
bytes required to represent the enum as a result. As long as the enum is
repr(C), repr(int), or repr(C, int), this will consistently return
whether the enum contains any padding bytes.