Skip to content

Commit 126715e

Browse files
committed
Comment on leading | in match arms
cc #119
1 parent 5c5c00d commit 126715e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

guide/expressions.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,22 @@ let x = match foo.bar.baz() {
499499

500500
Use a trailing comma for a match arm if and only if not using a block.
501501

502+
Never start a match arm pattern with `|`, e.g.,
503+
504+
```rust
505+
match foo {
506+
// Don't do this.
507+
| foo => bar,
508+
// Or this.
509+
| a_very_long_pattern
510+
| another_pattern
511+
| yet_another_pattern
512+
| a_forth_pattern => {
513+
...
514+
}
515+
}
516+
```
517+
502518
Avoid splitting the left-hand side (before the `=>`) of a match arm where
503519
possible. If the right-hand side of the match arm is kept on the same line,
504520
never use a block (unless the block is empty).

0 commit comments

Comments
 (0)