generate_variant_structs

Function generate_variant_structs 

Source
fn generate_variant_structs(
    enum_name: &Ident,
    generics: &Generics,
    data: &DataEnum,
    zerocopy_crate: &Path,
) -> TokenStream
Expand description

Generates variant structs for the given enum variant.

These are structs associated with each variant of an enum. They are repr(C) tuple structs with the same fields as the variant after a MaybeUninit<___ZerocopyInnerTag>.

In order to unify the generated types for repr(C) and repr(int) enums, we use a “fused” representation with fields for both an inner tag and an outer tag. Depending on the repr, we will set one of these tags to the tag type and the other to (). This lets us generate the same code but put the tags in different locations.