Skip to content

Commit 3ec08d4

Browse files
committed
add short paragraph on macro use case for mismatched bindings
1 parent 0765c16 commit 3ec08d4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

text/3637-guard-patterns.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ match Some(0) {
334334
}
335335
```
336336

337+
This is also very useful for macros, because it allows
338+
1. pattern macros to use guard patterns freely without introducing new bindings the user has to be aware of in order to use the pattern macro within a disjunction, and
339+
2. macro users to pass guard patterns to macros freely, even if the macro uses the pattern within a disjunction.
340+
337341
As mentioned above, this case is not covered by this RFC, because `x` would need to be bound in both cases of the disjunction.
338342

339343
However, we could support this by automatically detecting that `x` is not ever used outside of the guard pattern, and allowing the guard to capture the binding, so it wouldn't have to be bound in other cases of the disjunction.

0 commit comments

Comments
 (0)