How to make a async function that returns a future

Code

Pin<Box<dyn Future<Output = (bool, Option<Box<dyn Fn(&mut Context) -> ()>>)>>>

Error

Box::pin(Box::new((true, None)))
(bool, Option<_>)` is not a future

Box::pin creates a new box, not pin an existing one.

Try:

Box::pin((true, None))

edit: oops yeah @Alice is right, maybe I should take a break from thinking for a bit :sweat_smile:

If you want the actual type that you wrote, then you should do this:

Box::pin(async { (true, None) })

The async block is an expression that creates a future.

2 Likes

Thank you so much

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.