diff --git a/src/task/spawn.rs b/src/task/spawn.rs index f81a483d2..857d3f398 100644 --- a/src/task/spawn.rs +++ b/src/task/spawn.rs @@ -23,6 +23,30 @@ use crate::task::{Builder, JoinHandle}; /// # /// # }) /// ``` +/// +/// ```ignore +/// use async_std::task; +/// use std::time::Duration; +/// +/// async fn clock() { +/// loop { +/// task::sleep(Duration::from_secs(1)).await; +/// println!("Tick"); +/// } +///} +/// +/// #[async_std::main] +/// async fn main() { +/// println!("Start"); +/// task::spawn(clock()); +/// +/// for i in (0..=10).rev() { +/// println!("Countdown {}", i); +/// task::sleep(Duration::from_secs(2)).await; +/// } +/// println!("End"); +///} +/// ``` pub fn spawn(future: F) -> JoinHandle where F: Future + Send + 'static,