docs: add config info for match_arm_leading_pipes
This commit is contained in:
parent
4908ee19c3
commit
f6b96254fb
1 changed files with 82 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue