diff options
| author | Yacin Tmimi <yacintmimi@gmail.com> | 2023-06-23 00:05:31 -0400 |
|---|---|---|
| committer | Caleb Cartwright <calebcartwright@users.noreply.github.com> | 2023-07-01 01:06:35 -0500 |
| commit | 7b4e8a6d31a9b1ae404934a348f33cadf33ee764 (patch) | |
| tree | 507e864f4d295151f238e798f34d3300589e14e8 | |
| parent | fe8b72d98e58e05420be9c1227ebdbe7a742dcf9 (diff) | |
| download | rust-7b4e8a6d31a9b1ae404934a348f33cadf33ee764.tar.gz rust-7b4e8a6d31a9b1ae404934a348f33cadf33ee764.zip | |
update `else_block_exceeds_width` calculation in `let-else` rewrite
By reversing the logic I felt that the code became a clearer. Also, added a comment to make it clear that we need to take the trailing semicolon for the `let-else` statement into account.
| -rw-r--r-- | src/items.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/items.rs b/src/items.rs index 157ae931a24..fe35953715c 100644 --- a/src/items.rs +++ b/src/items.rs @@ -156,7 +156,8 @@ impl Rewrite for ast::Local { rewrite_let_else_block(block, allow_single_line, context, shape)?; let single_line_else = !rw_else_block.contains('\n'); - let else_block_exceeds_width = available_space <= rw_else_block.len(); + // +1 for the trailing `;` + let else_block_exceeds_width = rw_else_block.len() + 1 > available_space; if allow_single_line && single_line_else && else_block_exceeds_width { // writing this on one line would exceed the available width |
