Update block checking code

This commit is contained in:
Bryce Van Dyk 2015-12-02 16:44:40 +13:00
parent 7ce887abcf
commit 74d40c042f

View File

@ -960,14 +960,15 @@ impl Rewrite for ast::Arm {
let budget = context.config.max_width - line_start - comma.len() - 4; 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 offset = Indent::new(offset.block_indent, line_start + 4 - offset.block_indent);
let rewrite = nop_block_collapse(body.rewrite(context, budget, offset), budget); let rewrite = nop_block_collapse(body.rewrite(context, budget, offset), budget);
let is_body_str_block = match rewrite { let is_block = if let ast::ExprBlock(ref block) = body.node {
Some(ref s) => s.trim().starts_with("{") && s.trim().ends_with("}"), true
None => false, } else {
false
}; };
match rewrite { match rewrite {
Some(ref body_str) if !body_str.contains('\n') || !context.config.wrap_match_arms || Some(ref body_str) if !body_str.contains('\n') || !context.config.wrap_match_arms ||
is_body_str_block => { is_block => {
return Some(format!("{}{} => {}{}", return Some(format!("{}{} => {}{}",
attr_str.trim_left(), attr_str.trim_left(),
pats_str, pats_str,