enum MealTime {
Breakfast,
Lunch,
Dinner,
}
for n in 1..3 {
let mealc: MealTime = match n {
1 => MealTime::Breakfast,
2 => MealTime::Lunch,
3 => MealTime::Dinner,
};
At first I tried doing for meal in MealTime {}
but discovered that would not work because rust does not support iterating through enums (at least not by default or without implementing the trait yourself). So then I decided to just use a standard for loop ranged by an integer only to realize that using the iterator to match a variable to one of the enums types causes an error:
error[E0004]: non-exhaustive patterns: i32::MIN..=0_i32
and 4_i32..=i32::MAX
not covered.
How is this supposed to be done? I would think that matching for all 3 cases of n being 1, 2, and 3 would work.