2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-04-08 01:16:41 +00:00
This commit is contained in:
tronta 2025-03-17 17:40:37 +00:00 committed by GitHub
commit 62f214fade
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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<F, T>(future: F) -> JoinHandle<T>
where
F: Future<Output = T> + Send + 'static,