-
-
Notifications
You must be signed in to change notification settings - Fork 729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Procedural API for SumType #10650
Procedural API for SumType #10650
Conversation
Thanks for your pull request and interest in making D better, @pbackus! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + phobos#10650" |
Does this need a changelog entry or a corresponding GH issue? Beyond that I approve of this. |
Added a changelog entry. |
CI failure appears to be a bug in the ImportC test suite:
[...]
|
This has been sitting with the 72h no objection -> merge label for 4 days, so I'm clicking merge. |
This change introduces three new convenience functions that allow code using SumType to be written in a more procedural style (as opposed to the functional style of match). * has!T checks whether a SumType contains a value of type T. * get!T accesses a SumType's value if it has type T, or asserts if it does not. * tryGet!T is like get!T, but throws an exception instead of asserting on failure. To make room for get!T, the existing SumType.get method is renamed to getByIndex. Phobos PR: dlang/phobos#10650
This change introduces three new convenience functions that allow code using SumType to be written in a more procedural style (as opposed to the functional style of match). * has!T checks whether a SumType contains a value of type T. * get!T accesses a SumType's value if it has type T, or asserts if it does not. * tryGet!T is like get!T, but throws an exception instead of asserting on failure. To make room for get!T, the existing SumType.get method is renamed to getByIndex. Frontend requirement is bumped to 2.103 for __traits(fullyQualifiedName). Phobos PR: dlang/phobos#10650
This PR introduces three new convenience functions that allow code using
SumType
to be written in a more procedural style (as opposed to the functional style ofmatch
).has!T
checks whether aSumType
contains a value of typeT
.get!T
accesses aSumType
's value if it has typeT
, or asserts if it does not.tryGet!T
is likeget!T
, but throws an exception instead of asserting on failure.To make room for
get!T
, the existingSumType.get
method is renamed togetByIndex
.CC @atilaneves since this introduces new public symbols
CC @jmdavis who requested this in the community Discord