-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hyper client guide does not compile #1296
Comments
It is not possible to use |
I changed the client guide example to:
To make it compile but was not able to find the OK result type, any help? (Once I got this I will submit a PR to fix the guide since I'm sure I was not the only one with this issue :)) |
The following link describes a workaround The following link describes a proposal for a language change that would allow users to use ? in main |
A simple fix is to The working example should be: 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().unwrap();
let client = Client::new(&core.handle());
let uri = "http://httpbin.org/ip".parse().unwrap();
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).unwrap();
} The Rust Programming Language book has a section on the subject of panics
Http exceptions can usually be responded to by retrying a few times and then informing the user to check if that particular website is down and troubleshoot their internet connection. In many cases, an http client will not have access to network troubleshooting/control, or can simply be run a second time by the user. |
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?The text was updated successfully, but these errors were encountered: