-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support
co_return;
in coro Expected
of empty trivial types like `…
…Unit` Summary: Allow `Expected<Unit, E>` coros to return void -- aka `co_return;` or reaching the `}` closing the function. To do this, I add an `expected_detail::Promise` specialization for `Value` that is both trivial and empty, and refactor the methods that can be shared with the value-returning case into `PromiseBase`. This is an interface change for existing `Expected` coroutines -- they need to use `co_await makeUnexpected(...)` instead of `co_return makeUnexpected(...)`. Unlike `co_return`, it's possible for `co_await` to suspend the coroutine, which is potentially slower. In D51537604, yfeldblum measured / optimized this case a bit, so this is (hopefully) now acceptable in exchange for improved readability. Reviewed By: yfeldblum Differential Revision: D49253265 fbshipit-source-id: a18b407fa023fed22ef86a18116da2bacd93f30a
- Loading branch information
1 parent
a53ef85
commit 3113fbf
Showing
2 changed files
with
74 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters