is this a "safe" way of getting the std::mem::Discriminant value for an enum variant without actually initializing the variant? obviously cursed but would it ever really cause problems?
unsafe {
let value = std::mem::MaybeUninit::new(Enum::Variant {
a: std::mem::MaybeUninit::zeroed().assume_init(),
b: std::mem::MaybeUninit::zeroed().assume_init(),
});
std::mem::discriminant(value.assume_init_ref())
}
I guess it depends on whether the discriminant function does anything with the non-discriminant memory, but surely not?