From 7b4e8a6d31a9b1ae404934a348f33cadf33ee764 Mon Sep 17 00:00:00 2001 From: Yacin Tmimi Date: Fri, 23 Jun 2023 00:05:31 -0400 Subject: 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. --- src/items.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 -- cgit 1.4.1-3-g733a5