futuretest/src/main.rs

43 lines
872 B
Rust

#![feature(conservative_impl_trait)]
extern crate futures;
extern crate tokio_core;
use futures::future::{self};
use futures::future::*;
use tokio_core::reactor::Core;
enum ErrorCode
{
Case1,
Case2,
}
fn main() {
let mut core = Core::new().expect("Failed to initialize tokio_core reactor!");
let f = async_entry_point()
.or_else(move |err| {
//the problem is that the three matches below resolve to different anonymized types
match err {
ErrorCode::Case1 => case1(),
ErrorCode::Case2 => case2(),
}
})
;
core.run(f);
}
fn async_entry_point() -> impl Future<Item=(), Error=ErrorCode> {
future::ok(())
}
fn case1() -> impl Future<Item=(), Error=ErrorCode> {
future::ok(())
}
fn case2() -> impl Future<Item=(), Error=ErrorCode> {
future::ok(())
}