我想使用 reqwest
发出异步 HTTP 请求箱。我有以下代码:
// see https://docs.rs/reqwest/*/reqwest/async/index.html
use reqwest::async::Client;
当我尝试编译我的代码时,出现以下错误:
error: expected identifier, found reserved keyword `async`
--> src/main.rs:1:14
|
1 | use reqwest::async::Client;
| ^^^^^ expected identifier, found reserved keyword
如何从 async
模块导入?
最佳答案
因为 reqwest::async
是在 async
之前创建的,它是一个保留关键字(我相信它发生在 Rust 2018 中)之前这个 Just Worked™。
既然 async
是保留关键字,您需要使用 raw identifier语法:
use request::r#async::Client;
关于syntax - 尝试导入 `reqwest::async` 错误说明 `async` 是保留关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54733766/