Enum 'tags', manually assigned?


would there be any demand to be able to say this sort of thing,

enum FBB{

e.g. to spell out a specific assignment of tags for interoperability with C manually rolled tagged unions / symmetry with binary formats .
(spelling out starting at 0 or 1, or possibly existing uneven assignment of variants that leaves room for adding in the middle)

(I know we seem to have manual assignment for dataless enums)


I’d probably use a Rust untagged union (note: nightly only) and manually implement an equivalent of my enum as a tagged union for the FFI layer. That would probably be more beneficial than what you are proposing because it’s more explicit how things are laid out in memory.

Also, note that #[repr(u32)] is only defined for C-style enums. My understanding is that the annotation means “this entire thing can be represented in memory using a u32”, so having data members like f32 or String wouldn’t make sense because it’d require more room than is available.