-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement single_line_let_else_max_width
This allows users to configure the maximum length of a single line `let-else` statements. `let-else` statements that otherwise meet the requirements to be formatted on a single line will have their divergent `else block` formatted over multiple lines if they exceed this length.
- Loading branch information
Showing
19 changed files
with
258 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
tests/source/configs/single_line_let_else_max_width/100.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// rustfmt-single_line_let_else_max_width: 100 | ||
|
||
fn main() { | ||
let Some(a) = opt else {}; | ||
|
||
let Some(b) = opt else { return }; | ||
|
||
let Some(c) = opt else { | ||
return | ||
}; | ||
|
||
let Some(d) = some_very_very_very_very_long_name else { return }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// rustfmt-single_line_let_else_max_width: 50 | ||
|
||
fn main() { | ||
let Some(a) = opt else {}; | ||
|
||
let Some(b) = opt else { return }; | ||
|
||
let Some(c) = opt else { | ||
return | ||
}; | ||
|
||
let Some(d) = some_very_very_very_very_long_name else { return }; | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/source/configs/single_line_let_else_max_width/zero.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// rustfmt-single_line_let_else_max_width: 0 | ||
|
||
fn main() { | ||
let Some(a) = opt else {}; | ||
|
||
let Some(b) = opt else { return }; | ||
|
||
let Some(c) = opt else { | ||
return | ||
}; | ||
|
||
let Some(d) = some_very_very_very_very_long_name else { return }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
tests/target/configs/single_line_let_else_max_width/100.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// rustfmt-single_line_let_else_max_width: 100 | ||
|
||
fn main() { | ||
let Some(a) = opt else {}; | ||
|
||
let Some(b) = opt else { return }; | ||
|
||
let Some(c) = opt else { return }; | ||
|
||
let Some(d) = some_very_very_very_very_long_name else { return }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// rustfmt-single_line_let_else_max_width: 50 | ||
|
||
fn main() { | ||
let Some(a) = opt else {}; | ||
|
||
let Some(b) = opt else { return }; | ||
|
||
let Some(c) = opt else { return }; | ||
|
||
let Some(d) = some_very_very_very_very_long_name else { | ||
return; | ||
}; | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/target/configs/single_line_let_else_max_width/zero.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// rustfmt-single_line_let_else_max_width: 0 | ||
|
||
fn main() { | ||
let Some(a) = opt else {}; | ||
|
||
let Some(b) = opt else { | ||
return; | ||
}; | ||
|
||
let Some(c) = opt else { | ||
return; | ||
}; | ||
|
||
let Some(d) = some_very_very_very_very_long_name else { | ||
return; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.