try_future

Build Status Dependency Status crates.io

This crate aims to provide a convenient short-hand for returning early from futures-based functions.

The general pattern it supports is where before a function performs an asynchonous task, it does some work that might result in an early termination, for example:

Examples

Using impl Future<_> (nightly)

```rust

[macrouse] extern crate tryfuture;

fn makerequest(target: &str, client: &Client) -> impl Future { let uri = tryfuture!(target.parse::());

client.get(uri).into()

} ```

Using Box<Future<_>>

```rust

[macrouse] extern crate tryfuture;

fn makerequest(target: &str, client: &Client) -> Box> { let uri = tryfuture_box!(target.parse::());

Box::new(client.get(uri))

} ```