Conversation
|
Thanks for your pull request and interest in making D better, @IDONTUSEGH! 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 + dmd#22753" |
if (int value = result) {
assert(value == 42);
}This syntax would be better but I couldn't figure out how to implement yet. |
|
Unfortunately The unwrapping action to pair it with the check is actually pretty simple to implement: https://github.com/dlang/dmd/pull/22570/changes#diff-11fb0212c55c05ed6e743e6776abb3c56996381760c8725255c622f96f5d9d4bR1705 My PR has been changed from the DIP for it, after feedback that people wanted it to be more explicit. It now requires a call to |
This PR implements
opImplicitCast, a user defined implicit conversion operator inspired by OpenD. After reviewing past forum discussions, I found this idea has been proposed before.With
opImplicitCast, we can implement #22715 entirely in user code (with some limitations). The same mechanism also enables the Result/Option/Maybe pattern:(This was suggested here: https://forum.dlang.org/post/gkqthkjhmjngnqkjzwya@forum.dlang.org)