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.
This commit is contained in:
parent
fe8b72d98e
commit
7b4e8a6d31
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user