Skip to content

Commit c11aac0

Browse files
committed
Update wrap_match_arms option tests and visual guide
1 parent be55f85 commit c11aac0

7 files changed

+14
-31
lines changed

Configurations.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,7 +1986,7 @@ Break comments to fit on the line
19861986

19871987
## `wrap_match_arms`
19881988

1989-
Wrap multiline match arms in blocks
1989+
Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms
19901990

19911991
- **Default value**: `true`
19921992
- **Possible values**: `true`, `false`
@@ -1995,13 +1995,9 @@ Wrap multiline match arms in blocks
19951995

19961996
```rust
19971997
match lorem {
1998-
true => {
1999-
let ipsum = dolor;
2000-
println!("{}", ipsum);
2001-
}
2002-
false => {
2003-
println!("{}", sit)
2004-
}
1998+
true =>
1999+
foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
2000+
false => println!("{}", sit),
20052001
}
20062002
```
20072003

@@ -2010,8 +2006,7 @@ match lorem {
20102006
```rust
20112007
match lorem {
20122008
true => {
2013-
let ipsum = dolor;
2014-
println!("{}", ipsum);
2009+
foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
20152010
}
20162011
false => println!("{}", sit),
20172012
}

src/config.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,8 @@ create_config! {
570570
wrap_comments: bool, false, "Break comments to fit on the line";
571571
comment_width: usize, 80, "Maximum length of comments. No effect unless wrap_comments = true";
572572
normalize_comments: bool, false, "Convert /* */ comments to // comments where possible";
573-
wrap_match_arms: bool, true, "Wrap multiline match arms in blocks";
573+
wrap_match_arms: bool, true, "Wrap the body of arms in blocks when it does not fit on \
574+
the same line with the pattern of arms";
574575
match_block_trailing_comma: bool, false,
575576
"Put a trailing comma after a block based match arm (non-block arms are not affected)";
576577
indent_match_arms: bool, true, "Indent match arms instead of keeping them at the same \

tests/source/configs-wrap_match_arms-false.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33

44
fn main() {
55
match lorem {
6-
true => {
7-
let ipsum = dolor;
8-
println!("{:?}", ipsum);
9-
}
6+
true => foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
107
false => {
118
println!("{}", sit)
129
}

tests/source/configs-wrap_match_arms-true.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33

44
fn main() {
55
match lorem {
6-
true => {
7-
let ipsum = dolor;
8-
println!("{}", ipsum);
9-
}
6+
true => foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
107
false => {
118
println!("{}", sit)
129
}

tests/target/configs-wrap_match_arms-false.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@
33

44
fn main() {
55
match lorem {
6-
true => {
7-
let ipsum = dolor;
8-
println!("{:?}", ipsum);
9-
}
10-
false => {
11-
println!("{}", sit)
12-
}
6+
true =>
7+
foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
8+
false => println!("{}", sit),
139
}
1410
}

tests/target/configs-wrap_match_arms-true.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
fn main() {
55
match lorem {
66
true => {
7-
let ipsum = dolor;
8-
println!("{}", ipsum);
7+
foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
98
}
109
false => println!("{}", sit),
1110
}

tests/target/match-nowrap.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
fn foo() {
66
match x {
7-
a => {
8-
foo()
9-
}
7+
a => foo(),
108
b => (
119
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
1210
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,

0 commit comments

Comments
 (0)