diff --git a/cargo.out b/cargo.out index d2607d1..c391764 100644 --- a/cargo.out +++ b/cargo.out @@ -1,22 +1,22 @@ Compiling futuretest v0.1.0 (file:///mnt/c/Users/Mahmoud/git/futuretest) error[E0271]: type mismatch resolving ` as futures::IntoFuture>::Error == &str` - --> src/main.rs:13:10 + --> src/main.rs:12:10 | -13 | .and_then(|_| +12 | .and_then(|_| | ^^^^^^^^ expected struct `std::string::String`, found &str | = note: expected type `std::string::String` found type `&str` -error[E0271]: type mismatch resolving ` as futures::IntoFuture>::Error == &str` - --> src/main.rs:20:10 +error[E0599]: no method named `and_then` found for type `futures::AndThen, [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 | -20 | core.run(f).unwrap(); - | ^^^ expected struct `std::string::String`, found &str +17 | .and_then(|_| future::result::<(), String>(Err("another &'static str error".to_owned()))) + | ^^^^^^^^ | - = note: expected type `std::string::String` - found type `&str` - = note: required because of the requirements on the impl of `futures::Future` for `futures::AndThen, [closure@src/main.rs:11:18: 11:43]>, [closure@src/main.rs:12:14: 12:67]>, futures::FutureResult<(), std::string::String>, [closure@src/main.rs:13:19: 16:14]>` + = note: the method `and_then` exists but the following trait bounds were not satisfied: + `futures::AndThen, [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, [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 diff --git a/src/main.rs b/src/main.rs index fe2d780..3b5cb62 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,14 +7,14 @@ use tokio_core::reactor::Core; fn main() { let mut core = Core::new().expect("Failed to initialize tokio_core reactor!"); - let f = future::result(Ok(())) - .map_err(|()| "&'static str error") - .map(|_| future::result(Err("another &'static str error"))) + 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();