Skip to content

Commit 12564f1

Browse files
docs: add config info for match_arm_leading_pipes
1 parent 180cd82 commit 12564f1

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

Configurations.md

+82
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,88 @@ fn main() {
15041504

15051505
See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
15061506

1507+
## `match_arm_leading_pipes`
1508+
1509+
Controls whether to include a leading pipe on match arms
1510+
1511+
- **Default value**: `Never`
1512+
- **Possible values**: `Always`, `Never`, `KeepExisting`
1513+
- **Stable**: Yes
1514+
1515+
#### `Never` (default):
1516+
```rust
1517+
// Leading pipes are from this:
1518+
// fn foo() {
1519+
// match foo {
1520+
// | "foo" | "bar" => {}
1521+
// | "baz"
1522+
// | "something relatively long"
1523+
// | "something really really really realllllllllllllly long" => println!("x"),
1524+
// | "qux" => println!("y"),
1525+
// _ => {}
1526+
// }
1527+
// }
1528+
1529+
// Are removed:
1530+
fn foo() {
1531+
match foo {
1532+
"foo" | "bar" => {}
1533+
"baz"
1534+
| "something relatively long"
1535+
| "something really really really realllllllllllllly long" => println!("x"),
1536+
"qux" => println!("y"),
1537+
_ => {}
1538+
}
1539+
}
1540+
```
1541+
1542+
#### `Always`:
1543+
```rust
1544+
// Leading pipes are emitted on all arms of this:
1545+
// fn foo() {
1546+
// match foo {
1547+
// "foo" | "bar" => {}
1548+
// "baz"
1549+
// | "something relatively long"
1550+
// | "something really really really realllllllllllllly long" => println!("x"),
1551+
// "qux" => println!("y"),
1552+
// _ => {}
1553+
// }
1554+
// }
1555+
1556+
// Becomes:
1557+
fn foo() {
1558+
match foo {
1559+
| "foo" | "bar" => {}
1560+
| "baz"
1561+
| "something relatively long"
1562+
| "something really really really realllllllllllllly long" => println!("x"),
1563+
| "qux" => println!("y"),
1564+
| _ => {}
1565+
}
1566+
}
1567+
```
1568+
1569+
#### `KeepExisting`:
1570+
```rust
1571+
fn foo() {
1572+
match foo {
1573+
| "foo" | "bar" => {}
1574+
| "baz"
1575+
| "something relatively long"
1576+
| "something really really really realllllllllllllly long" => println!("x"),
1577+
| "qux" => println!("y"),
1578+
_ => {}
1579+
}
1580+
1581+
match baz {
1582+
"qux" => {}
1583+
"foo" | "bar" => {}
1584+
_ => {}
1585+
}
1586+
}
1587+
```
1588+
15071589
## `match_block_trailing_comma`
15081590

15091591
Put a trailing comma after a block based match arm (non-block arms are not affected)

0 commit comments

Comments
 (0)