Skip to content

tokeio asynchronous function must be executed with 'await' #6989

Answered by Noah-Kennedy
zhangxize asked this question in Q&A
Discussion options

You must be logged in to vote

Futures in Rust are lazy. An async function or block effectively builds a state machine which is evaluated when awaited (which basically joins the awaited future as a subcomponent of the awaiting future) or spawned on a runtime. Async/await is best thought of as syntactic sugar for building state machines that can be polled to be advanced, and woken for later resumption.

A future is an object representing a computation that can be advanced until it needs to wait for an IO event, at which point it will need to be polled again by a runtime.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mox692
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants