Rust

Rust

By DeepSource

Found unnecessary usage of async RS-W1101

Anti-pattern

Defining blocks or functions as async without actually using .await inside them adds noise to the code for the readers and makes using the function unnecessarily complicated.

Consider revisiting this async block/function.

Examples

Bad practice

async fn foo() {
    let x = 10;
    println!("{x}");
}

async fn bar() {
    async_runtime::run(async {
        let items = fetch().await;
        println!("{items:?}");
    }); // not using await directly
}