gpt4 book ai didi

syntax - 尝试导入 `reqwest::async` 错误说明 `async` 是保留关键字

转载 作者:行者123 更新时间:2023-11-29 07:57:59 28 4
gpt4 key购买 nike

我想使用 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com