Skip to content

Conversation

akonradi-signal
Copy link

This provides a different behavior for Option<F> than the existing futures_util::future::Option future: instead of resolving to Option<F::Output> it resolves to F::Output if the future is present; otherwise it does not resolve.

This can be useful for code paths that select! on multiple futures where one of the futures is optional. Using this wrapper allows sharing code paths since if the optional future is not present, that select! arm simply won't resolve.

This provides a different behavior for `Option<F>` than the existing
Option future: instead of resolving to `Option<F::Output>` it resolves
to `F::Output` if the future is present; otherwise it does not resolve.

This can be useful for code paths that `select!` on multiple futures
where one of the futures is optional. Using this wrapper allows sharing
code paths since if the optional future is not present, that `select!`
arm simply won't resolve.
@rustbot rustbot added A-future Area: futures::future S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 15, 2025
@akonradi-signal
Copy link
Author

We've been using something like this in libsignal for a while and it's been generally useful, so I figured it might be useful more broadly as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-future Area: futures::future S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants