Repository: seanmonstar/reqwest (language: rust)

Issue:
Examples with `?` operator not working?
Hi there, I'm new to Rust so this might not be related to `reqwest`. As far as I understand the `?` operator can only be used inside functions that return a `Result`. However in the examples this isn't mentioned. Simply running the first example:
```rust
let text = reqwest::get("https://www.rust-lang.org")?
    .text()?;

println!("body = {:?}", body);
```
Returns `cannot use the ? operator in a function that returns ()` and `body not found in this scope`. Then changing the code to:
```rust
let text = reqwest::get("https://www.rust-lang.org")
    .text();

println!("text = {:?}", text);
```
Returns `no method named text found for type std::result::Result<reqwest::Response, reqwest::Error>`, any help appreciated.


Discussion / hints:
try:

```rust
extern crate reqwest;

fn foo() -> Result<(), reqwest::Error> {
    let text = reqwest::get("https://www.rust-lang.org")?
        .text()?;
    
    println!("body = {:?}", text);
    Ok(())
}

fn main() {
    foo().unwrap();
}
```
Thanks @messense that works & confirms my guess that it only works within a function returning a `Result`. Do you think it's a good idea to simplify the example so it works anywhere in `main`? For me it caused some confusion.
The examples were changed to show using `?` because the community as a whole wanted to move away from showing examples where errors just cause crashes (by `unwrap`ing all errors). Eventually (seems like about a couple months), it'll be possible to return an error from the `main` function, and so examples can be update to that!

In the meantime, this might be helpful: have the very first example show using in `fn main` and an auxiliary `fn run`, simply calling `run().unwrap()` in main. Then, have a note after the example that all other examples assume a similar setup. What do you think of that?
I dug into this a bit and indeed found it is [the recommended way](https://rust-lang-nursery.github.io/api-guidelines/documentation.html#examples-use--not-try-not-unwrap-c-question-mark) to write examples. I'm fond of copy and pasting snippets to try but I can see how this provides a cleaner way of showing functionality. Guess most people won't get as confused as I was about the `?` unless they're completely new to Rust like me.

Will create a PR!

Fix patch:
diff --git a/src/lib.rs b/src/lib.rs
index 8a7d2bbe4..18a13d356 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -25,6 +25,25 @@
 //! applications that only require a few HTTP requests, and wish to handle
 //! them synchronously.
 //!
+//! ## Code example structure
+//! Note that all the following examples expect to be run outside of `main` because `?` is used. Like so:
+//!
+//! ```rust
+//! use reqwest::{Error, Response};
+//!
+//! fn run() -> Result<(), Error> {
+//!     let body = reqwest::get("https://www.rust-lang.org")?
+//!         .text()?;
+//!
+//!     println!("body = {:?}", body);
+//!     Ok(())
+//! }
+//!
+//! fn main() {
+//!     run();
+//! }
+//! ```
+//!
 //! ## Making a GET request
 //!
 //! For a single request, you can use the [`get`][get] shortcut method.


Test patch: