Hacker News new | ask | show | jobs
by trevyn 2266 days ago
Async/await in Rust compiles down to a state machine (and to my understanding, uses generators under the hood):

https://rust-lang.github.io/async-book/01_getting_started/04...

1 comments

Generators are currently unstable, but the crate genawaiter[1] allows you to use them on stable.

We have used that crate at work to replace a very scary and verbose state machine (which was generating a lot more code via procedural macros) with a much more succinct version.

[1]: https://docs.rs/genawaiter/0.2.2/genawaiter/