[−][src]Function runtime::task::spawn
ⓘImportant traits for JoinHandle<T>
pub fn spawn<F, T>(fut: F) -> JoinHandle<T> where
F: Future<Output = T> + Send + 'static,
T: Send + 'static,
Spawn a future on the runtime's thread pool.
This function can only be called after a runtime has been initialized.
Examples
#![feature(async_await)] #[runtime::main] async fn main() { let handle = runtime::spawn(async { println!("running the future"); 42 }); assert_eq!(handle.await, 42); }