]> git.lizzy.rs Git - rust.git/blob - src/docs/async_yields_async.txt
Auto merge of #9425 - kraktus:patch-1, r=xFrednet
[rust.git] / src / docs / async_yields_async.txt
1 ### What it does
2 Checks for async blocks that yield values of types
3 that can themselves be awaited.
4
5 ### Why is this bad?
6 An await is likely missing.
7
8 ### Example
9 ```
10 async fn foo() {}
11
12 fn bar() {
13   let x = async {
14     foo()
15   };
16 }
17 ```
18
19 Use instead:
20 ```
21 async fn foo() {}
22
23 fn bar() {
24   let x = async {
25     foo().await
26   };
27 }
28 ```