尝试导入“reqwest::async”错误,指出“async”是保留关键字
Attempting to import `reqwest::async` errors stating that `async` is a reserved keyword
我想使用 reqwest
crate 发出异步 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;
我想使用 reqwest
crate 发出异步 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;