[英]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.