[英]Error in Rust unit test: "The async keyword is missing from the function declaration"
[英]the `async` keyword is missing from the function declaration when compile rust project
当我使用这个命令 cargo build 编译 rust 项目时,显示如下错误:
➜ reddwarf-admin git:(main) ✗ cargo build
Compiling reddwarf-admin v0.1.0 (/Users/xiaoqiangjiang/source/reddwarf/backend/reddwarf-admin)
error: the `async` keyword is missing from the function declaration
--> src/main.rs:48:7
|
48 | async fn main() {
| ^^
这是我的 fn function 看起来像:
#[rocket::main]
#[tokio::main]
async fn main() {
tokio::spawn(refresh_channel_rep());
tokio::spawn(refresh_channel_article_count());
tokio::spawn(remove_low_quality_articles());
tokio::spawn(calculate_article_trend());
let launch_result = create_server().launch().await;
match launch_result {
Ok(_) => println!("Rocket shut down gracefully."),
Err(err) => println!("Rocket had an error: {}", err),
};
}
我已经尝试在main.rs
中添加 tokio micro,如下所示:
#[macro_use]
extern crate tokio;
问题还是没有解决,为什么会这样? 我应该怎么做才能解决这个问题?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.