3 ms·
One very common reason is to make the code non-blocking. In fact Rust's async/await system works by converting the code into a state machine. Unfortunately Rus
by IshKebab 2y ago
One very common reason is to make the code non-blocking. In fact Rust's async/await system works by converting the code into a state machine.
Unfortunately Rust doesn't have proper support for coroutines or generators yet so often you'll want to use a hand written state machine anyway.
Even if it did, sometimes the problem domain means that a state machine naturally fits the semantics better than using a control flow based approach anyway.