尝试导入“ reqwest :: async”错误,指出“ async”是保留关键字

时间:2019-02-17 13:31:50

标签: syntax rust reqwest rust-2018

我想使用reqwest条板箱发出异步HTTP请求。我有以下代码:

$ docker run --rm -it --shm-size=1G alpine sh -c 'mount | grep shm'
shm on /dev/shm type tmpfs (rw,seclabel,nosuid,nodev,noexec,relatime,size=1048576k)`

当我尝试编译代码时,出现以下错误:

// 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 模块导入?

1 个答案:

答案 0 :(得分:5)

由于reqwest::asyncasync是保留关键字(我相信在Rust 2018中发生)之前是在Just Justed™之前创建的。

现在async是保留关键字,您需要使用raw identifier语法:

use request::r#async::Client;
相关问题