没有为`std :: result :: Result< reqwest :: Response,reqwest :: Error>`实现特性`std :: future

编程入门 行业动态 更新时间:2024-10-28 04:20:48
本文介绍了没有为`std :: result :: Result< reqwest :: Response,reqwest :: Error>`实现特性`std :: future :: Future`.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试运行基本的reqwest 示例:

I'm trying to run basic reqwest example:

extern crate reqwest; extern crate tokio; #[tokio::main] async fn main() -> Result<(), reqwest::Error> { let res = reqwest::Client::new() .get("hyper.rs") .send() .await?; println!("Status: {}", res.status()); let body = res.text().await?; println!("Body:\n\n{}", body); Ok(()) }

我遇到的错误:

--> src/main.rs:6:15 | 6 | let res = reqwest::Client::new() | _______________^ 7 | | .get("hyper.rs") 8 | | .send() 9 | | .await?; | |______________^ the trait `std::future::Future` is not implemented for `std::result::Result<reqwest::Response, reqwest::Error>`

Rust版本:rustc 1.39.0 (4560ea788 2019-11-04)

库版本:

reqwest = "0.9.22" tokio = { version = "0.2.0-alpha.6", features = ["full"] }

有人知道这是怎么回事吗?

Does anybody know what is wrong here?

推荐答案

与此处相同,只是相反.您正在使用reqwest-0.9,默认情况下使用的是阻止接口.更新到reqwest-0.10以获得异步接口.

Same problem as here, just in reverse. You are using reqwest-0.9, which is using the blocking interface by default. Update to reqwest-0.10 to get the async interface.

如果无法更新到reqwest-0.10,则reqwest-0.9中的异步接口位于reqwest::async中.例如. reqwest::async::Client::new(...).

If you can't update to reqwest-0.10, the async interface in reqwest-0.9 is in reqwest::async. E.g. reqwest::async::Client::new(...).

更多推荐

没有为`std :: result :: Result&lt; reqwest :: Response,reqwest :: Error&gt;

本文发布于:2023-11-26 06:01:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1632925.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:特性   amp   lt   Result   std

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!