#async #future #marked #type #wrap #must-use #box-futures

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

#544 in Asynchronous

Download history 1217/week @ 2023-11-20 674/week @ 2023-11-27 616/week @ 2023-12-04 962/week @ 2023-12-11 698/week @ 2023-12-18 263/week @ 2023-12-25 343/week @ 2024-01-01 964/week @ 2024-01-08 1009/week @ 2024-01-15 1054/week @ 2024-01-22 886/week @ 2024-01-29 1295/week @ 2024-02-05 478/week @ 2024-02-12 594/week @ 2024-02-19 765/week @ 2024-02-26 1096/week @ 2024-03-04

2,981 downloads per month
Used in 78 crates (12 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

~1MB
~16K SLoC