5
5
>   ;  ; [ _ Expression_ ] ` . ` ` await `
6
6
7
7
Await expressions are legal only within ` async ` contexts, like an
8
- ` async fn ` or an ` async ` block. They operate on a future. Their effect
8
+ [ ` async fn ` ] or an [ ` async ` block] . They operate on a [ future] . Their effect
9
9
is to suspend the current computation until the given future is ready
10
10
to produce a value.
11
11
12
12
More specifically, an ` <expr>.await ` expression has the following effect.
13
13
14
14
1 . Evaluate ` <expr> ` to a [ future] ` tmp ` ;
15
- 2 . Pin ` tmp ` using ` Pin::new_unchecked ` ;
15
+ 2 . Pin ` tmp ` using [ ` Pin::new_unchecked ` ] ;
16
16
3 . This pinned future is then polled by calling the [ ` Future::poll ` ] method and
17
- passing it the current task context (see below );
17
+ passing it the current [ task context] ( #task-context ) ;
18
18
3 . If the call to ` poll ` returns [ ` Poll::Pending ` ] , then the future
19
19
returns ` Poll::Pending ` , suspending its state so that, when the
20
20
surrounding async context is re-polled, execution returns to step
@@ -23,10 +23,13 @@ More specifically, an `<expr>.await` expression has the following effect.
23
23
value contained in the [ ` Poll::Ready ` ] variant is used as the result
24
24
of the ` await ` expression itself.
25
25
26
+ [ `async fn` ] : ../items/functions.md#async-functions
27
+ [ `async` block ] : block-expr.md#async-blocks
26
28
[ future ] : ../../std/future/trait.Future.html
27
29
[ _Expression_ ] : ../expressions.md
28
30
[ `Future::poll` ] : ../../std/future/trait.Future.html#tymethod.poll
29
31
[ `Context` ] : ../../std/task/struct.Context.html
32
+ [ `Pin::new_unchecked` ] : ../../std/pin/struct.Pin.html#method.new_unchecked
30
33
[ `Poll::Pending` ] : ../../std/task/enum.Poll.html#variant.Pending
31
34
[ `Poll::Ready` ] : ../../std/task/enum.Poll.html#variant.Ready
32
35
0 commit comments