[][src]Macro futures::spawn_with_handle

macro_rules! spawn_with_handle {
    ( $ future : expr ) => { ... };

Spawns a task onto the context's executor that polls the given future to completion and returns a future that resolves to the spawned future's output.

This macro returns a Result that contains a JoinHandle, or, if spawning fails, a SpawnError. JoinHandle is a future that resolves to the output of the spawned future


#![feature(async_await, await_macro, futures_api)]
use futures::{future, spawn_with_handle};

let future = future::ready(1);
let join_handle = spawn_with_handle!(future).unwrap();
assert_eq!(await!(join_handle), 1);