One is the async block (a closure with async block as its body to be precise), while the other is async closure. Per async/await RFC:
async ||
closuresIn addition to functions, async can also be applied to closures. Like an async function, an async closure has a return type of
impl Future<Output = T>
, rather thanT
.
On the other hand:
async
blocksYou can create a future directly as an expression using an
async
block. This form is almost equivalent to an immediately-invokedasync
closure:async { /* body */ } // is equivalent to (async || { /* body */ })()
except that control-flow constructs like
return
,break
andcontinue
are not allowed within body.
The move
keyword here is to denote that the async closure and block are to capture ownership of the variables they close over.
And apparently, async closure is still deemed to be unstable. It has this tracking issue.