A common pattern is to define a type alias for Result that hides the error type. It seems like they are using the alias in reqwest, however the example in the book seems to be missing an import of this type alias.
I would recommend you add this type alias:
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
Edit: You can view any hidden lines by pressing the arrows in the upper right of the example. They are using the error_chain crate to introduce the type alias, but for simplicity I would simply use a box like I did above.
Setting a default of T = () can also be convenient if you have a lot of functions that don't return anything on success. Then you can write things like:
> error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
> --> src/main.rs:38:19
> |
> 38 | let mut res = reqwest::get("http://www.marca.es")?;
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `?` operator cannot be applied to type `impl std::future::Future`
> |
> = help: the trait `std::ops::Try` is not implemented for `impl std::future::Future`
> = note: required by `std::ops::Try::into_result`
>
> error[E0308]: mismatched types
> --> src/main.rs:30:14
> |
> 30 | fn main() -> Result<()> {
> | ---- ^^^^^^^^^^ expected enum `std::result::Result`, found `()`
> | |
> | implicitly returns `()` as its body has no tail or `return` expression
> ...
> 45 | Ok(());
> | - help: consider removing this semicolon
> |
> = note: expected enum `std::result::Result<(), Error>`
> found unit type `()`
error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
--> src/main.rs:38:19
|
38 | let mut res = reqwest::get("http://www.marca.es")?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `?` operator cannot be applied to type `impl std::future::Future`
|
= help: the trait `std::ops::Try` is not implemented for `impl std::future::Future`
= note: required by `std::ops::Try::into_result`
I recommend you read the error message. You can only use ? on values of type Result or Option depending on what your function returns. A future is neither of those.
The example is using an old version of reqwest, although it looks like the version number listed on the page has been incorrectly updated to the latest version.
But fair enough that you are confused about the error then.