Асинхронные блоки

Изменения в новых версиях / Rust 1.39

// *** before: ***
// a future value was assembled out of ready made combinators
let task = futures::future::ok::<_, Error>(2).map(|x| x * 2);

// *** in version 1.39: ***
// an async block is an expression that yields a future
let task = async {
    let x = fetch_number().await?;
    Ok::<_, Error>(x * 2)
};

// async move takes the captured values for itself
let name = String::from("prod");
let named = async move {
    println!("{}", name);
};