Skip to content

Commit 2fa9839

Browse files
duration in required but int was passed
sleep requires a Duration, not a number directly.
1 parent 781e5f5 commit 2fa9839

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/part-guide/async-await.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,15 @@ The syntax for using await is `some_future.await`, i.e., it is a postfix keyword
7878
Consider the following functions:
7979

8080
```rust,norun
81+
use tokio::time::{sleep, Duration};
82+
8183
// An async function, but it doesn't need to wait for anything.
8284
async fn add(a: u32, b: u32) -> u32 {
8385
a + b
8486
}
8587
8688
async fn wait_to_add(a: u32, b: u32) -> u32 {
87-
sleep(1000).await;
89+
sleep(Duration::from_millis(1000)).await;
8890
a + b
8991
}
9092
```

0 commit comments

Comments
 (0)