Article

Async In Rust

总结一下如何在Rust中实现异步流程.

  • Notes
  • Computer

async和await是语法糖

see a block marked with the async keyword -> compiles it into a unique, anonymous data type that implements the Future trait.

when see a func marked with async, it compiles it into a non-async func whose body is an async block.

a program’s main function can initialize a runtime, but it’s not a runtime itself.

Most languages that support async bundle a runtime, but Rust does not

something has to execute this state machine, and that something is runtime.

executor in runtime : the part of a runtime responsible for executing the async code

to be continued...