From 74d40c042f9f2d6d39881465aca91a4daf1ea7a9 Mon Sep 17 00:00:00 2001 From: Bryce Van Dyk Date: Wed, 2 Dec 2015 16:44:40 +1300 Subject: [PATCH] Update block checking code --- src/expr.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/expr.rs b/src/expr.rs index cc518003e88..78c3a82e223 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -960,14 +960,15 @@ impl Rewrite for ast::Arm { let budget = context.config.max_width - line_start - comma.len() - 4; let offset = Indent::new(offset.block_indent, line_start + 4 - offset.block_indent); let rewrite = nop_block_collapse(body.rewrite(context, budget, offset), budget); - let is_body_str_block = match rewrite { - Some(ref s) => s.trim().starts_with("{") && s.trim().ends_with("}"), - None => false, + let is_block = if let ast::ExprBlock(ref block) = body.node { + true + } else { + false }; match rewrite { Some(ref body_str) if !body_str.contains('\n') || !context.config.wrap_match_arms || - is_body_str_block => { + is_block => { return Some(format!("{}{} => {}{}", attr_str.trim_left(), pats_str,