Open
Description
trait Async {
type Value;
type Error;
}
enum Result<T, E> {
Ok(T),
Err(E),
}
impl<T, E> Result<T, E> {
fn reduce<F, U>(self, init: U::Value, action: F) -> U::Value
where F: Fn(U::Value, T) -> U,
U: Async<Error=E> {
unimplemented!();
}
}
impl Async for i32 {
type Value = i32;
type Error = ();
}
pub fn main() {
let res: Result<&'static str, ()> = Result::Ok("hello");
let val: i32 = 123;
res.reduce(val, |val /* i32 */, curr| val);
// Compiles if annotated ^^
}