Compare commits

..

No commits in common. "futures-rs-683" and "master" have entirely different histories.

2 changed files with 13 additions and 52 deletions

@ -1,22 +1,14 @@
Compiling futuretest v0.1.0 (file:///mnt/d/GIT/futuretest) Compiling futuretest v0.1.0 (file:///mnt/c/Users/Mahmoud/git/futuretest)
error[E0308]: match arms have incompatible types error[E0277]: the trait bound `(): futures::Future` is not satisfied
--> src/main.rs:28:13 --> src/main.rs:17:1
| |
28 | / match err { 17 | / fn test() -> MapErr<(), ()> {
29 | | ErrorCode::CanHandleWithAsync => async_error_handler() 18 | | future::ok(())
30 | | .map_err(|_| ErrorCode::CannotHandle).wait(), 19 | | .map_err(|String| ())
31 | | ErrorCode::CanHandleWithSync => future::result(sync_error_handler()), 20 | | }
32 | | ErrorCode::CannotHandle => future::err(ErrorCode::CannotHandle), | |_^ the trait `futures::Future` is not implemented for `()`
33 | | }
| |_____________^ expected enum `std::result::Result`, found struct `futures::FutureResult`
| |
= note: expected type `std::result::Result<(), ErrorCode>` = note: required by `futures::MapErr`
found type `futures::FutureResult<(), ErrorCode>`
note: match arm with an incompatible type
--> src/main.rs:31:49
|
31 | ErrorCode::CanHandleWithSync => future::result(sync_error_handler()),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error error: aborting due to previous error

@ -2,50 +2,19 @@
extern crate futures; extern crate futures;
extern crate tokio_core; extern crate tokio_core;
use futures::future::{self, FutureResult}; use futures::future::{self};
use futures::future::*; use futures::future::*;
use tokio_core::reactor::Core; use tokio_core::reactor::Core;
#[derive(Debug)]
enum ErrorCode
{
CanHandleWithAsync,
CanHandleWithSync,
CannotHandle
}
#[derive(Debug)]
enum ErrorCode2
{
}
fn main() { fn main() {
let mut core = Core::new().expect("Failed to initialize tokio_core reactor!"); let mut core = Core::new().expect("Failed to initialize tokio_core reactor!");
let f = async_entry_point() let f = test();
.or_else(move |err| {
//the problem is that the three matches below resolve to different future types
match err {
ErrorCode::CanHandleWithAsync => async_error_handler()
.map_err(|_| ErrorCode::CannotHandle).wait(),
ErrorCode::CanHandleWithSync => future::result(sync_error_handler()),
ErrorCode::CannotHandle => future::err(ErrorCode::CannotHandle),
}
})
;
core.run(f).unwrap(); core.run(f).unwrap();
} }
fn async_entry_point() -> FutureResult<(), ErrorCode> { fn test() -> MapErr<(), ()> {
future::ok(()) future::ok(())
.map_err(|String| ())
} }
fn async_error_handler() -> FutureResult<(), ErrorCode2> {
future::ok(())
}
fn sync_error_handler() -> Result<(), ErrorCode> {
Ok(())
}