Skip to content

Commit 24a3123

Browse files
authored
Merge pull request #127 from rust-lang-nursery/leading-pipe
Comment on leading `|` in match arms
2 parents f7ccf5e + 126715e commit 24a3123

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
@@ -594,6 +594,22 @@ let x = match foo.bar.baz() {
594594

595595
Use a trailing comma for a match arm if and only if not using a block.
596596

597+
Never start a match arm pattern with `|`, e.g.,
598+
599+
```rust
600+
match foo {
601+
// Don't do this.
602+
| foo => bar,
603+
// Or this.
604+
| a_very_long_pattern
605+
| another_pattern
606+
| yet_another_pattern
607+
| a_forth_pattern => {
608+
...
609+
}
610+
}
611+
```
612+
597613
Avoid splitting the left-hand side (before the `=>`) of a match arm where
598614
possible. If the right-hand side of the match arm is kept on the same line,
599615
never use a block (unless the block is empty).

0 commit comments

Comments
 (0)