Compare commits

..

1 Commits

Author SHA1 Message Date
Mahmoud Al-Qudsi d5bfaf7c98 Illustrating alexcrichton/futures-rs/#676 2017-12-09 13:33:08 -06:00
3 changed files with 28 additions and 20 deletions

@ -1,5 +1,4 @@
CARGO = cargo +$(TOOLCHAIN)
TOOLCHAIN = nightly
CARGO = cargo
.PHONY: all bench build check clean doc install publish run test update
@ -9,7 +8,7 @@ bench:
@$(CARGO) bench
build:
@env TERM=xterm-256color $(CARGO) build --color=always 2>&1; $(CARGO) build 2> cargo.out 1>/dev/null
@env TERM=xterm-256color $(CARGO) build --color=always 2>&1
check: build test

@ -1,16 +1,24 @@
Compiling futuretest v0.1.0 (file:///mnt/c/Users/Mahmoud/git/futuretest)
error[E0277]: the trait bound `(): futures::Future` is not satisfied
--> src/main.rs:17:1
error[E0271]: type mismatch resolving `<futures::FutureResult<(), std::string::String> as futures::IntoFuture>::Error == &str`
--> src/main.rs:12:10
|
17 | / fn test() -> MapErr<(), ()> {
18 | | future::ok(())
19 | | .map_err(|String| ())
20 | | }
| |_^ the trait `futures::Future` is not implemented for `()`
12 | .and_then(|_|
| ^^^^^^^^ expected struct `std::string::String`, found &str
|
= note: required by `futures::MapErr`
= note: expected type `std::string::String`
found type `&str`
error: aborting due to previous error
error[E0599]: no method named `and_then` found for type `futures::AndThen<futures::MapErr<futures::FutureResult<(), ()>, [closure@src/main.rs:11:18: 11:42]>, futures::FutureResult<(), std::string::String>, [closure@src/main.rs:12:19: 15:14]>` in the current scope
--> src/main.rs:17:10
|
17 | .and_then(|_| future::result::<(), String>(Err("another &'static str error".to_owned())))
| ^^^^^^^^
|
= note: the method `and_then` exists but the following trait bounds were not satisfied:
`futures::AndThen<futures::MapErr<futures::FutureResult<(), ()>, [closure@src/main.rs:11:18: 11:42]>, futures::FutureResult<(), std::string::String>, [closure@src/main.rs:12:19: 15:14]> : futures::Future`
`&mut futures::AndThen<futures::MapErr<futures::FutureResult<(), ()>, [closure@src/main.rs:11:18: 11:42]>, futures::FutureResult<(), std::string::String>, [closure@src/main.rs:12:19: 15:14]> : futures::Future`
error: aborting due to 2 previous errors
error: Could not compile `futuretest`.

@ -1,5 +1,3 @@
#![feature(conservative_impl_trait)]
extern crate futures;
extern crate tokio_core;
use futures::future::{self};
@ -9,12 +7,15 @@ use tokio_core::reactor::Core;
fn main() {
let mut core = Core::new().expect("Failed to initialize tokio_core reactor!");
let f = test();
let f = future::result::<(),()>(Ok(()))
.map_err(|_| "&'static str error")
.and_then(|_|
future::result(Ok(())
.map_err(|()| "String error".to_owned())
)
)
.and_then(|_| future::result::<(), String>(Err("another &'static str error".to_owned())))
;
core.run(f).unwrap();
}
fn test() -> MapErr<(), ()> {
future::ok(())
.map_err(|String| ())
}