diff options
| author | C4K3 <github25b@c4k3.net> | 2017-03-26 07:32:29 +0200 |
|---|---|---|
| committer | Nick Cameron <nrc@ncameron.org> | 2017-03-26 18:32:29 +1300 |
| commit | abca1dededc504eeff7fb31fb2f92e54c7ddae0e (patch) | |
| tree | 176cc589852c7f712d70ca6c2d049d562a761cbb /tests/source | |
| parent | 0dd0cc1941d5ef8222e36d54b0efd38628d589ee (diff) | |
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.
Diffstat (limited to 'tests/source')
| -rw-r--r-- | tests/source/indent_match_arms.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/source/indent_match_arms.rs b/tests/source/indent_match_arms.rs new file mode 100644 index 00000000000..ecadbe705ff --- /dev/null +++ b/tests/source/indent_match_arms.rs @@ -0,0 +1,27 @@ +// rustfmt-indent_match_arms: false + +fn main() { + match x { + 1 => "one", + 2 => "two", + 3 => "three", + 4 => "four", + 5 => "five", + _ => "something else", + } + + match x { + 1 => "one", + 2 => "two", + 3 => "three", + 4 => "four", + 5 => match y { + 'a' => 'A', + 'b' => 'B', + 'c' => 'C', + _ => "Nope", + }, + _ => "something else", + } + +} |
