docs: add config info for match_arm_leading_pipes

This commit is contained in:
Caleb Cartwright 2020-09-23 22:05:56 -05:00 committed by Caleb Cartwright
parent 4908ee19c3
commit f6b96254fb

View file

@ -1463,6 +1463,88 @@ fn main() {
See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
## `match_arm_leading_pipes`
Controls whether to include a leading pipe on match arms
- **Default value**: `Never`
- **Possible values**: `Always`, `Never`, `Preserve`
- **Stable**: Yes
#### `Never` (default):
```rust
// Leading pipes are removed from this:
// fn foo() {
// match foo {
// | "foo" | "bar" => {}
// | "baz"
// | "something relatively long"
// | "something really really really realllllllllllllly long" => println!("x"),
// | "qux" => println!("y"),
// _ => {}
// }
// }
// Becomes
fn foo() {
match foo {
"foo" | "bar" => {}
"baz"
| "something relatively long"
| "something really really really realllllllllllllly long" => println!("x"),
"qux" => println!("y"),
_ => {}
}
}
```
#### `Always`:
```rust
// Leading pipes are emitted on all arms of this:
// fn foo() {
// match foo {
// "foo" | "bar" => {}
// "baz"
// | "something relatively long"
// | "something really really really realllllllllllllly long" => println!("x"),
// "qux" => println!("y"),
// _ => {}
// }
// }
// Becomes:
fn foo() {
match foo {
| "foo" | "bar" => {}
| "baz"
| "something relatively long"
| "something really really really realllllllllllllly long" => println!("x"),
| "qux" => println!("y"),
| _ => {}
}
}
```
#### `Preserve`:
```rust
fn foo() {
match foo {
| "foo" | "bar" => {}
| "baz"
| "something relatively long"
| "something really really really realllllllllllllly long" => println!("x"),
| "qux" => println!("y"),
_ => {}
}
match baz {
"qux" => {}
"foo" | "bar" => {}
_ => {}
}
}
```
## `match_block_trailing_comma`
Put a trailing comma after a block based match arm (non-block arms are not affected)