Skip to content

Commit 88cb142

Browse files
authored
Merge pull request #1895 from topecongiro/configs-match_pattern_separator_break_point
Add mach_pattern_separator_break_point config option
2 parents 4fcbf7f + 5cf05a2 commit 88cb142

15 files changed

+294
-176
lines changed

Configurations.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,39 @@ match lorem {
11631163

11641164
See also: [`indent_match_arms`](#indent_match_arms), [`trailing_comma`](#trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
11651165

1166+
## `match_pattern_separator_break_point`
1167+
1168+
Put a match sub-patterns' separator (`|`) in front or back.
1169+
1170+
- **Default value**: `"Back"`
1171+
- **Possible values**: `"Back"`, `"Front"`
1172+
1173+
#### `"Back"`
1174+
1175+
```rust
1176+
match m {
1177+
Variant::Tag |
1178+
Variant::Tag2 |
1179+
Variant::Tag3 |
1180+
Variant::Tag4 |
1181+
Variant::Tag5 |
1182+
Variant::Tag6 => {}
1183+
}
1184+
```
1185+
1186+
#### `Front`
1187+
1188+
```rust
1189+
match m {
1190+
Variant::Tag
1191+
| Variant::Tag2
1192+
| Variant::Tag3
1193+
| Variant::Tag4
1194+
| Variant::Tag5
1195+
| Variant::Tag6 => {}
1196+
}
1197+
```
1198+
11661199
## `max_width`
11671200

11681201
Maximum width of each line

src/config.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::io::{Error, ErrorKind, Read};
1717
use std::path::{Path, PathBuf};
1818

1919
use file_lines::FileLines;
20-
use lists::{ListTactic, SeparatorTactic};
20+
use lists::{ListTactic, SeparatorPlace, SeparatorTactic};
2121

2222
macro_rules! configuration_option_enum{
2323
($e:ident: $( $x:ident ),+ $(,)*) => {
@@ -581,6 +581,8 @@ create_config! {
581581
"Put a trailing comma after a block based match arm (non-block arms are not affected)";
582582
indent_match_arms: bool, true, "Indent match arms instead of keeping them at the same \
583583
indentation level as the match keyword";
584+
match_pattern_separator_break_point: SeparatorPlace, SeparatorPlace::Back,
585+
"Put a match sub-patterns' separator in front or back.";
584586
closure_block_indent_threshold: isize, 7, "How many lines a closure must have before it is \
585587
block indented. -1 means never use block indent.";
586588
space_before_type_annotation: bool, false,

0 commit comments

Comments
 (0)