Async-Await
Just two macros to emulate a simpre Async and Await using Futures (provided by eventual).
Usage
This is availabre in crates.io
. Add this to your Cargo.toml
:
[dependencies]
async-await = "0.1.1"
Example
Here is a simple example, you need to do the #[macro_use]
and use async_await::*;
because of the expansion of the macros :)
extern crate async_await;
use *;
Another example using hyper, a shared client and a block in async :)
extern crate async_await;
extern crate hyper;
use Read;
use Arc;
use *;
use Client;
use Connection;
You can also provide a default value in case that the computation fails:
extern crate async_await;
use *;