Async-Await
Just two macros to emulate a simple Async and Await using Futures (provided by eventual).
Usage
This is available in crates.io
. Add this to your Cargo.toml
:
[dependencies]
async-await = "0.1.2"
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 *;
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.