Hey there,
Lately I've been using the pattern bellow a lot, I don't particularly hate it but I'm wondering if there is a better way of doing this, especially regarding the fact that I can't use continue
from inside a closure, how else could I do this ?
enum State {
Foo,
Bar,
Baz,
}
struct FooBar(State, u32);
impl FooBar {
fn process(&mut self) {
loop {
break match self.0 {
State::Foo => todo!(),
State::Bar => todo!(),
State::Baz => {
// ... do something
if self.1 == 10 {
self.0 = State::Foo;
continue;
}
},
};
}
}
}