From abca1dededc504eeff7fb31fb2f92e54c7ddae0e Mon Sep 17 00:00:00 2001 From: C4K3 Date: Sun, 26 Mar 2017 07:32:29 +0200 Subject: Add indent_match_arms option (#1404) Makes it optional whether to indent arms in match expressions. Setting this to false may be desirable for people wishing to avoid double-indents, in that if the match arm is a block, the block will cause an extra indentation level, and if it isn't a block but just a single line, it's still easy to see the logic at a glance. This style is preferred in certain other languages with switch statements, e.g. Linux style C and the most common Java style. --- src/expr.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/expr.rs') diff --git a/src/expr.rs b/src/expr.rs index 1df0f2a96d0..6ab9e1c3393 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -1137,7 +1137,12 @@ fn rewrite_match(context: &RewriteContext, }; let mut result = format!("match {}{}{{", cond_str, block_sep); - let arm_shape = shape.block_indent(context.config.tab_spaces); + let arm_shape = if context.config.indent_match_arms { + shape.block_indent(context.config.tab_spaces) + } else { + shape.block_indent(0) + }; + let arm_indent_str = arm_shape.indent.to_string(context.config); let open_brace_pos = context.codemap.span_after(mk_sp(cond.span.hi, arm_start_pos(&arms[0])), -- cgit 1.4.1-3-g733a5