[][src]Module drone_core::future::fallback

Fallback syntax for async/await when libcore-drone crate is not available.

The following snippet is written with native async/await syntax:

use drone_core::sync::spsc::oneshot;

async fn plus_one(rx: oneshot::Receiver<usize>) -> Result<usize, oneshot::Canceled> {
    let number = rx.await?;
    Ok(number + 1)
}

Using this module that snippet can be rewritten as follow:

use drone_core::{future::fallback::*, sync::spsc::oneshot};
use futures::prelude::*;

fn plus_one(
    rx: oneshot::Receiver<usize>,
) -> impl Future<Output = Result<usize, oneshot::Canceled>> {
    asyn(|| {
        let number = awt!(rx)?;
        Ok(number + 1)
    })
}

Functions

asyn

Wrap a generator in a future.