futuretest/src/main.rs

43 lines
872 B
Rust

2017-12-13 09:34:46 -06:00
#![feature(conservative_impl_trait)]
extern crate futures;
extern crate tokio_core;
use futures::future::{self};
use futures::future::*;
use tokio_core::reactor::Core;
2017-12-24 18:32:27 -06:00
enum ErrorCode
{
Case1,
Case2,
}
fn main() {
let mut core = Core::new().expect("Failed to initialize tokio_core reactor!");
2017-12-24 18:32:27 -06:00
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(),
}
})
;
2017-12-24 18:32:27 -06:00
core.run(f);
}
fn async_entry_point() -> impl Future<Item=(), Error=ErrorCode> {
future::ok(())
}
2017-12-13 09:34:46 -06:00
2017-12-24 18:32:27 -06:00
fn case1() -> impl Future<Item=(), Error=ErrorCode> {
2017-12-13 09:34:46 -06:00
future::ok(())
}
2017-12-24 18:32:27 -06:00
fn case2() -> impl Future<Item=(), Error=ErrorCode> {
future::ok(())
}