Skip to content

Commit 0032122

Browse files
committed
rfc, or-patterns: note about macros in guide.
1 parent 1ad3e9d commit 0032122

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

text/0000-or-patterns.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,19 @@ You can also use `p | q` in:
433433
This restriction is currently enforced to avoid backtracking but may possibly
434434
be lifted in the future based on other developments in the grammar.
435435

436+
6. macros by example:
437+
438+
```rust
439+
macro_rules! foo {
440+
($p:pat) => { ... }
441+
}
442+
443+
foo!((Ok(x) | Err(x)));
444+
```
445+
446+
Here we must wrap the pattern in parenthesis since `$p:pat | $q:pat` is
447+
already legal in patterns.
448+
436449
# Reference-level explanation
437450
[reference-level-explanation]: #reference-level-explanation
438451

0 commit comments

Comments
 (0)