Rust

Rust

Made by DeepSource

Found explicitly ignored future value RS-E1035

Bug risk
Major

A Future is a suspended computation unit which must be driven to completion by polling it. Hence, when a Future value is ignored, it is not polled to completion, leading to any errors that might occur at the time of Future computation execution not being handled. This can lead to unexpected behaviour if the program assumes that the code in Future would run.

Bad practice

async fn foo() -> u32 {
    get_count().await
}
fn main() {
    let _ = foo(); // bad
    _ = foo(); // bad
}

Recommended

async fn foo() -> u32 {
    get_count().await
}
fn main() {
    let _ = foo().await; // fine
    _ = foo().await; // fine
    let x = foo(); // fine
}