mirror of
https://github.com/async-rs/async-std.git
synced 2025-03-28 20:16:41 +00:00
Adding example to docs
This commit is contained in:
parent
cc85533f7c
commit
33e7c87dfc
1 changed files with 15 additions and 0 deletions
|
@ -360,6 +360,21 @@ extension_trait! {
|
||||||
#[doc = r#"
|
#[doc = r#"
|
||||||
Waits for both the future and a timeout, if the timeout completes before
|
Waits for both the future and a timeout, if the timeout completes before
|
||||||
the future, it returns an TimeoutError.
|
the future, it returns an TimeoutError.
|
||||||
|
|
||||||
|
# Example
|
||||||
|
```
|
||||||
|
#async_std::task::block_on(async {
|
||||||
|
let fut = future::ready(0);
|
||||||
|
let dur = Duration::from_millis(100);
|
||||||
|
let res = fut.timeout(dur).await;
|
||||||
|
assert!(res.is_ok());
|
||||||
|
|
||||||
|
let fut = future::ready(0);
|
||||||
|
let dur = Duration::from_millis(100);
|
||||||
|
let res = fut.timeout(dur).await;
|
||||||
|
assert!(res.is_ok())
|
||||||
|
# });
|
||||||
|
```
|
||||||
"#]
|
"#]
|
||||||
#[cfg(any(feature = "unstable", feature = "docs"))]
|
#[cfg(any(feature = "unstable", feature = "docs"))]
|
||||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||||
|
|
Loading…
Reference in a new issue