In Rust Async Await is implemented using state machines. So is there is any way to view that intermediate representation of state machine for learning purpose?
You can look at the MIR output of the compiler. This is a control-flow graph representation, with basic blocks and jumps. For an async
function or block, you will see that the MIR body starts with a basic block with a switchInt
terminator, i.e. a jump table: depending on the current state of the state machine, jump to a particular basic block.
You can see the MIR output on the Rust playground, by choosing the MIR output in the "..." menu in the top-left corner. Alternatively, you can ask the Rust compiler for the MIR output. See here for more details, but the invocation should be like: rustc [filename].rs --emit mir