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