3 ms·
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_getti
by trevyn 7y 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_async_await_primer.html https://rust-lang.github.io/async-book/01_getting_started/04...
- luckysori 7y agoGenerators 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/ https://docs.rs/genawaiter/0.2.2/genawaiter/