Skip to content

Commit

Permalink
Update wrap_match_arms option tests and visual guide
Browse files Browse the repository at this point in the history
  • Loading branch information
topecongiro committed Jul 11, 2017
1 parent be55f85 commit c11aac0
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 31 deletions.
15 changes: 5 additions & 10 deletions Configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -1986,7 +1986,7 @@ Break comments to fit on the line

## `wrap_match_arms`

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

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

```rust
match lorem {
true => {
let ipsum = dolor;
println!("{}", ipsum);
}
false => {
println!("{}", sit)
}
true =>
foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
false => println!("{}", sit),
}
```

Expand All @@ -2010,8 +2006,7 @@ match lorem {
```rust
match lorem {
true => {
let ipsum = dolor;
println!("{}", ipsum);
foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
}
false => println!("{}", sit),
}
Expand Down
3 changes: 2 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,8 @@ create_config! {
wrap_comments: bool, false, "Break comments to fit on the line";
comment_width: usize, 80, "Maximum length of comments. No effect unless wrap_comments = true";
normalize_comments: bool, false, "Convert /* */ comments to // comments where possible";
wrap_match_arms: bool, true, "Wrap multiline match arms in blocks";
wrap_match_arms: bool, true, "Wrap the body of arms in blocks when it does not fit on \
the same line with the pattern of arms";
match_block_trailing_comma: bool, false,
"Put a trailing comma after a block based match arm (non-block arms are not affected)";
indent_match_arms: bool, true, "Indent match arms instead of keeping them at the same \
Expand Down
5 changes: 1 addition & 4 deletions tests/source/configs-wrap_match_arms-false.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

fn main() {
match lorem {
true => {
let ipsum = dolor;
println!("{:?}", ipsum);
}
true => foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
false => {
println!("{}", sit)
}
Expand Down
5 changes: 1 addition & 4 deletions tests/source/configs-wrap_match_arms-true.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

fn main() {
match lorem {
true => {
let ipsum = dolor;
println!("{}", ipsum);
}
true => foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
false => {
println!("{}", sit)
}
Expand Down
10 changes: 3 additions & 7 deletions tests/target/configs-wrap_match_arms-false.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@

fn main() {
match lorem {
true => {
let ipsum = dolor;
println!("{:?}", ipsum);
}
false => {
println!("{}", sit)
}
true =>
foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
false => println!("{}", sit),
}
}
3 changes: 1 addition & 2 deletions tests/target/configs-wrap_match_arms-true.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
fn main() {
match lorem {
true => {
let ipsum = dolor;
println!("{}", ipsum);
foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
}
false => println!("{}", sit),
}
Expand Down
4 changes: 1 addition & 3 deletions tests/target/match-nowrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

fn foo() {
match x {
a => {
foo()
}
a => foo(),
b => (
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
Expand Down

0 comments on commit c11aac0

Please sign in to comment.