Skip to content

Commit

Permalink
docs: add config info for match_arm_leading_pipes
Browse files Browse the repository at this point in the history
  • Loading branch information
calebcartwright committed May 10, 2020
1 parent 180cd82 commit 12564f1
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions Configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -1504,6 +1504,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`, `KeepExisting`
- **Stable**: Yes

#### `Never` (default):
```rust
// Leading pipes are from this:
// fn foo() {
// match foo {
// | "foo" | "bar" => {}
// | "baz"
// | "something relatively long"
// | "something really really really realllllllllllllly long" => println!("x"),
// | "qux" => println!("y"),
// _ => {}
// }
// }

// Are removed:
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"),
| _ => {}
}
}
```

#### `KeepExisting`:
```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)
Expand Down

0 comments on commit 12564f1

Please sign in to comment.