Closed
Description
[dependencies]
hyper = "0.11"
futures = "0.1"
tokio-core = "0.1"
tokio-io = "0.1"
extern crate futures;
extern crate hyper;
extern crate tokio_core;
use std::io::{self, Write};
use futures::{Future, Stream};
use hyper::Client;
use tokio_core::reactor::Core;
fn main(){
let mut core = Core::new()?;
let client = Client::new(&core.handle());
let uri = "http://httpbin.org/ip".parse()?;
let work = client.get(uri).and_then(|res| {
println!("Response: {}", res.status());
res.body().for_each(|chunk| {
io::stdout()
.write_all(&chunk)
.map_err(From::from)
})
});
core.run(work)?;
}
error[E0277]: the trait bound `(): std::ops::Try` is not satisfied
--> src/main.rs:11:16
|
11 | let mut core = Core::new()?;
| ------------
| |
| the trait `std::ops::Try` is not implemented for `()`
| in this macro invocation
|
= note: required by `std::ops::Try::from_error`
error[E0277]: the trait bound `(): std::ops::Try` is not satisfied
--> src/main.rs:14:11
|
14 | let uri = "http://httpbin.org/ip".parse()?;
| --------------------------------
| |
| the trait `std::ops::Try` is not implemented for `()`
| in this macro invocation
|
= note: required by `std::ops::Try::from_error`
error[E0277]: the trait bound `(): std::ops::Try` is not satisfied
--> src/main.rs:24:1
|
24 | core.run(work)?;
| ---------------
| |
| the trait `std::ops::Try` is not implemented for `()`
| in this macro invocation
|
= note: required by `std::ops::Try::from_error`
error: aborting due to previous error(s)
I had to wrap the code between fn main() {}
don't know if it's a documentation typo or not. It seems to not compile, what am I missing?
Metadata
Metadata
Assignees
Labels
No labels