Skip to content
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

trait bound not satified #580

Closed
CGQAQ opened this issue Nov 24, 2019 · 2 comments
Closed

trait bound not satified #580

CGQAQ opened this issue Nov 24, 2019 · 2 comments

Comments

@CGQAQ
Copy link

CGQAQ commented Nov 24, 2019

use async_std::prelude::*;
use async_std::task::block_on;

use reqwest::Client;

async fn run() -> Result<(),()> {
    let mut url = "";
    let res = Client::new().get(url).send().await?;
    let result = res.to_string();


    Ok(())
}

fn main(){
    block_on(run());
}
error[E0277]: the trait bound `std::result::Result<reqwest::response::Response, reqwest::error::Error>: std::future::Future` is not satisfied
   --> src/main.rs:11:15
    |
11  |     let res = Client::new().get(url).send().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`.

what the heck is this error? async function should be return Future of Output = std::result::Result<reqwest::response::Response, reqwest::error::Error>, why don't satisfy?How could I solve this?

@CGQAQ CGQAQ closed this as completed Nov 24, 2019
@yoshuawuyts
Copy link
Contributor

@CGQAQ to my knowledge reqwest only works with tokio out of the box. If you're looking for a runtime-agnostic HTTP client, surf might be an option.

@CGQAQ
Copy link
Author

CGQAQ commented Nov 25, 2019

@CGQAQ to my knowledge reqwest only works with tokio out of the box. If you're looking for a runtime-agnostic HTTP client, surf might be an option.

@yoshuawuyts Thank you very much, I already know whats happend, that's why I closed this issue.
reqwest 0.9.x depends on futures = "0.1.23", I am figured out that version of futures crate probably deprecated, don't work with .await anymore

And I also filed a new issue about this pretty frustrating experience issue page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants