Skip to content

Instantly share code, notes, and snippets.

@nikomatsakis
Created April 12, 2018 18:41
Show Gist options
  • Save nikomatsakis/58717b0588393ca14f2d6168e7c86188 to your computer and use it in GitHub Desktop.
Save nikomatsakis/58717b0588393ca14f2d6168e7c86188 to your computer and use it in GitHub Desktop.
struct Result<T, E> { }
trait Future {
type Output;
}
trait FutureResult
where
Self: Future<
Output = Result<
<Self as FutureResult>::Item,
<Self as FutureResult>::Error
>
>
{
type Item;
type Error;
}
impl<T, I, E> FutureResult for T
where T: Future<Output = Result<I, E>>
{
type Item = I;
type Error = E;
}
struct u32 { }
struct Error { }
struct MyFuture1 { }
impl Future for MyFuture1 {
type Output = u32;
}
struct MyFuture2 { }
impl Future for MyFuture2 {
type Output = Result<u32, Error>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment