@@ -1463,6 +1463,88 @@ fn main() {
1463
1463
1464
1464
See also: [ ` match_block_trailing_comma ` ] ( #match_block_trailing_comma ) .
1465
1465
1466
+ ## ` match_arm_leading_pipes `
1467
+
1468
+ Controls whether to include a leading pipe on match arms
1469
+
1470
+ - ** Default value** : ` Never `
1471
+ - ** Possible values** : ` Always ` , ` Never ` , ` Preserve `
1472
+ - ** Stable** : Yes
1473
+
1474
+ #### ` Never ` (default):
1475
+ ``` rust
1476
+ // Leading pipes are removed from this:
1477
+ // fn foo() {
1478
+ // match foo {
1479
+ // | "foo" | "bar" => {}
1480
+ // | "baz"
1481
+ // | "something relatively long"
1482
+ // | "something really really really realllllllllllllly long" => println!("x"),
1483
+ // | "qux" => println!("y"),
1484
+ // _ => {}
1485
+ // }
1486
+ // }
1487
+
1488
+ // Becomes
1489
+ fn foo () {
1490
+ match foo {
1491
+ " foo" | " bar" => {}
1492
+ " baz"
1493
+ | " something relatively long"
1494
+ | " something really really really realllllllllllllly long" => println! (" x" ),
1495
+ " qux" => println! (" y" ),
1496
+ _ => {}
1497
+ }
1498
+ }
1499
+ ```
1500
+
1501
+ #### ` Always ` :
1502
+ ``` rust
1503
+ // Leading pipes are emitted on all arms of this:
1504
+ // fn foo() {
1505
+ // match foo {
1506
+ // "foo" | "bar" => {}
1507
+ // "baz"
1508
+ // | "something relatively long"
1509
+ // | "something really really really realllllllllllllly long" => println!("x"),
1510
+ // "qux" => println!("y"),
1511
+ // _ => {}
1512
+ // }
1513
+ // }
1514
+
1515
+ // Becomes:
1516
+ fn foo () {
1517
+ match foo {
1518
+ | " foo" | " bar" => {}
1519
+ | " baz"
1520
+ | " something relatively long"
1521
+ | " something really really really realllllllllllllly long" => println! (" x" ),
1522
+ | " qux" => println! (" y" ),
1523
+ | _ => {}
1524
+ }
1525
+ }
1526
+ ```
1527
+
1528
+ #### ` Preserve ` :
1529
+ ``` rust
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
+ match baz {
1541
+ " qux" => {}
1542
+ " foo" | " bar" => {}
1543
+ _ => {}
1544
+ }
1545
+ }
1546
+ ```
1547
+
1466
1548
## ` match_block_trailing_comma `
1467
1549
1468
1550
Put a trailing comma after a block based match arm (non-block arms are not affected)
0 commit comments