First Draft: opUnwrapIfTrue
Paul Backus
snarwin at gmail.com
Thu Jul 16 23:01:40 UTC 2026
On Thursday, 16 July 2026 at 02:24:18 UTC, jmh530 wrote:
> Option 2 would be that it gets lowered to something like
> ```d
> if (match(x)
> {
> Some(value) => true,
> _ => false
> }) {
> use(value);
> }
> ```
>
> I would think that Option 2 would kind of be more in line with
> how rust handles in.
The issue with Option 2 is that the identifier `value` would not
be defined inside the body of the `if` statement.
> Once you start thinking about option 1, it gets harder to think
> about if you have `else if` parts.
Remember, `else if` is actually shorthand for
```d
else {
if (...) { ... }
}
```
So there's no need for a special rule to handle it--you just
treat it the same way as any other `else` block.
More information about the dip.development
mailing list