2 ms·
>very time you say `await` you start invisible magic happening. (A state machine starts spinning I believe in Rust - I may be mistaken) It's more that an async
by rcxdude 2y ago
>very time you say `await` you start invisible magic happening. (A state machine starts spinning I believe in Rust - I may be mistaken)
It's more that an async function in Rust is compiled completely differently: it's turned into a state machine at that point, with the code between 'awaits' being the transitions. In and of itself, it's not actually particularly difficult to grok (I'd say you have about as much an idea of what the resulting machine code looks like as with an optimized non-async function), the headaches are all in the edges of what the language can currently support when compiling under this model.