3 ms·
This is not a good design. You've introduced representable invalid states (Flavor=Vanilla, Other flavor="DarkChocolate"). At the least you want this... enum
by IshKebab 2y ago
This is not a good design. You've introduced representable invalid states (Flavor=Vanilla, Other flavor="DarkChocolate").
At the least you want this...
enum Flavor {
Chocolate,
Banana,
Strawberry,
Other(String),
}
But that's not right either. What you really want is
#[non_exhaustive]
enum Flavor {
Chocolate,
Banana,
Strawberry,
}
impl ToString for Flavor ...