Created
December 1, 2016 07:27
-
-
Save withoutboats/efaf0a34fd439c736bbed99342f0344c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate futures; | |
use futures::Future; | |
pub trait Foo: 'static { | |
fn parse(string: String) -> Box<Future<Item = Self, Error = ()>>; | |
} | |
pub trait Bar: 'static { | |
type Id: Foo; | |
fn get<'a>(id: &'a Self::Id) -> Box<Future<Item = Self, Error = ()> + 'a>; | |
} | |
fn foo_bar<T: Bar>(string: String) -> Box<Future<Item = T, Error = ()>> { | |
Box::new(<T::Id as Foo>::parse(string).and_then(|id| T::get(&id))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment