I have a large enum that has some struct variants, some tuple variants, and some tuple variants that wrap a struct. I'm wondering if this is considered bad style. Possibly it's better to be consistent and have every variant be struct-like?
Another option is to have all enums wrap a struct. This allows the enum data to be passed around easily.
What style do you use?
// Mixed
pub enum E1 {
Tag1(A, B),
Tag2 { c: C, d: D },
}
// Alternative 1: Always struct-like
pub enum E2 {
Tag1 { a: A, b: B },
Tag2 { c: C, d: D },
}
// Alternative 2: Always wrap a struct
pub enum E3 {
Tag1(Tag1),
Tag2(Tag2)
}
pub struct Tag1 {
pub a: A,
pub b: B,
}
pub struct Tag2 {
pub a: A,
pub b: B,
}