Skip to content

Commit 33e7c87

Browse files
committed
Adding example to docs
1 parent cc85533 commit 33e7c87

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/future/future/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,21 @@ extension_trait! {
360360
#[doc = r#"
361361
Waits for both the future and a timeout, if the timeout completes before
362362
the future, it returns an TimeoutError.
363+
364+
# Example
365+
```
366+
#async_std::task::block_on(async {
367+
let fut = future::ready(0);
368+
let dur = Duration::from_millis(100);
369+
let res = fut.timeout(dur).await;
370+
assert!(res.is_ok());
371+
372+
let fut = future::ready(0);
373+
let dur = Duration::from_millis(100);
374+
let res = fut.timeout(dur).await;
375+
assert!(res.is_ok())
376+
# });
377+
```
363378
"#]
364379
#[cfg(any(feature = "unstable", feature = "docs"))]
365380
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]

0 commit comments

Comments
 (0)