#asynchronous #future #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

#257 in Asynchronous

Download history 267/week @ 2020-11-04 471/week @ 2020-11-11 285/week @ 2020-11-18 232/week @ 2020-11-25 268/week @ 2020-12-02 399/week @ 2020-12-09 373/week @ 2020-12-16 118/week @ 2020-12-23 155/week @ 2020-12-30 238/week @ 2021-01-06 247/week @ 2021-01-13 185/week @ 2021-01-20 311/week @ 2021-01-27 191/week @ 2021-02-03 331/week @ 2021-02-10 311/week @ 2021-02-17

112 downloads per month
Used in 4 crates (via ghost_actor)

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