#future #async #must-use

must_future

A wrapper future marked must_use - mainly to wrap BoxFutures

3 releases

0.1.2 Jun 11, 2020
0.1.1 Apr 10, 2020
0.1.0 Apr 3, 2020

#964 in Asynchronous

Download history 747/week @ 2024-11-16 958/week @ 2024-11-23 783/week @ 2024-11-30 710/week @ 2024-12-07 941/week @ 2024-12-14 301/week @ 2024-12-21 284/week @ 2024-12-28 875/week @ 2025-01-04 1094/week @ 2025-01-11 747/week @ 2025-01-18 731/week @ 2025-01-25 869/week @ 2025-02-01 1078/week @ 2025-02-08 767/week @ 2025-02-15 854/week @ 2025-02-22 835/week @ 2025-03-01

3,824 downloads per month
Used in 74 crates (10 directly)

Apache-2.0

8KB
121 lines

Crates.io Crates.io

must_future

BoxFutures cannot be marked #[must_use] because they are just type definitions. This newtype struct wraps a BoxFuture with something that can be marked #[must_use].

Will Not Compile:

#![deny(unused_must_use)]

use futures::future::FutureExt;

#[tokio::main]
async fn main() {
    fn get_future() -> must_future::MustBoxFuture<'static, ()> {
        async { }.boxed().into()
    }

    get_future(); // unused `must_future::MustBoxFuture` that must be used
}

lib.rs:

BoxFutures cannot be marked #[must_use] because they are just type definitions. This newtype struct wraps a BoxFuture with something that can be marked #[must_use].

Will Not Compile:

#![deny(unused_must_use)]

use futures::future::FutureExt;

#[tokio::main]
async fn main() {
    fn get_future() -> must_future::MustBoxFuture<'static, ()> {
        async { }.boxed().into()
    }

    get_future(); // unused `must_future::MustBoxFuture` that must be used
}

Dependencies

~0.6–0.8MB
~15K SLoC