Hi,
I'm trying to run the simple.rs example of reqwest, but I can't get it to compile I've tried both stable and nightly.
I get the following error message when I cargo run
:
error[E0277]: the trait bound `std::result::Result<reqwest::response::Response, reqwest::error::Error>: std::future::Future` is not satisfied
--> src/main.rs:8:15
|
8 | let res = reqwest::get("https://hyper.rs").await?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::future::Future` is not implemented for `std::result::Result<reqwest::response::Response, reqwest::error::Error>`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
Here's the Cargo.toml I'm using:
[package]
name = "test_reqwest"
version = "0.1.0"
authors = ["ambiso <ambiso@invalid>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tokio = { version = "0.2", features = ["macros"] }
reqwest = "*"
And my main.rs:
use tokio;
use reqwest;
use std::collections::HashMap;
use std::future::Future;
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let res = reqwest::get("https://hyper.rs").await?;
println!("Status: {}", res.status());
let body = res.text().await?;
println!("Body:\n\n{}", body);
Ok(())
}
Am I doing something wrong? Or has the library not yet kept up with the async change?
Thanks for any help!
Best,
ambiso