pub enum Foo {}
```
-## `multiline_closure_forces_block`
+## `force_multiline_blocks`
-Force multiline closure bodies to be wrapped in a block
+Force multiline closure and match arm bodies to be wrapped in a block
- **Default value**: `false`
- **Possible values**: `false`, `true`
None => ...,
Some(value) => ...,
})
+
+match lorem {
+ None => if ipsum {
+ println!("Hello World");
+ },
+ Some(dolor) => ...,
+}
```
#### `true`:
Some(value) => ...,
}
})
-```
-
-## `multiline_match_arm_forces_block`
-
-Force multiline match arm bodies to be wrapped in a block
-
-- **Default value**: `false`
-- **Possible values**: `false`, `true`
-
-#### `false` (default):
-
-```rust
-match lorem {
- None => if ipsum {
- println!("Hello World");
- },
- Some(dolor) => ...,
-}
-```
-#### `true`:
-
-```rust
match lorem {
None => {
if ipsum {
}
```
+
## `newline_style`
Unix or Windows line endings
rewrite = and_one_line(rewrite);
}
rewrite = rewrite.and_then(|rw| {
- if context.config.multiline_closure_forces_block() && rw.contains('\n') {
+ if context.config.force_multiline_blocks() && rw.contains('\n') {
None
} else {
Some(rw)
// Match
wrap_match_arms: bool, true, false, "Wrap the body of arms in blocks when it does not fit on \
the same line with the pattern of arms";
- multiline_match_arm_forces_block: bool, false, false,
- "Force multiline match arm bodies to be wrapped in a block";
match_block_trailing_comma: bool, false, false,
"Put a trailing comma after a block based match arm (non-block arms are not affected)";
"Remove blank lines at start or end of a block";
same_line_attributes: bool, true, false,
"Try to put attributes on the same line as fields and variants.";
- multiline_closure_forces_block: bool, false, false,
- "Force multiline closure bodies to be wrapped in a block";
+ force_multiline_blocks: bool, false, false,
+ "Force multiline closure bodies and match arms to be wrapped in a block";
fn_args_density: Density, Density::Tall, false, "Argument density in functions";
brace_style: BraceStyle, BraceStyle::SameLineWhere, false, "Brace style for items";
control_brace_style: ControlBraceStyle, ControlBraceStyle::AlwaysSameLine, false,
{
if let ast::StmtKind::Expr(ref expr) = block.stmts[0].node {
(
- !context.config.multiline_match_arm_forces_block()
- && expr.can_be_overflowed(context, 1),
+ !context.config.force_multiline_blocks() && expr.can_be_overflowed(context, 1),
&**expr,
)
} else {
}
}
_ => (
- !context.config.multiline_match_arm_forces_block()
- && body.can_be_overflowed(context, 1),
+ !context.config.force_multiline_blocks() && body.can_be_overflowed(context, 1),
&*body,
),
}
--- /dev/null
+// rustfmt-force_multiline_blocks: false
+// Option forces multiline match arm and closure bodies to be wrapped in a block
+
+fn main() {
+ match lorem {
+ Lorem::Ipsum => {
+ if ipsum {
+ println!("dolor");
+ }
+ }
+ Lorem::Dolor => println!("amet"),
+ }
+}
+
+fn main() {
+ result.and_then(|maybe_value| {
+ match maybe_value {
+ None => Err("oops"),
+ Some(value) => Ok(1),
+ }
+ });
+}
--- /dev/null
+// rustfmt-force_multiline_blocks: true
+// Option forces multiline match arm and closure bodies to be wrapped in a block
+
+fn main() {
+ match lorem {
+ Lorem::Ipsum => if ipsum {
+ println!("dolor");
+ },
+ Lorem::Dolor => println!("amet"),
+ }
+}
+
+fn main() {
+ result.and_then(|maybe_value| match maybe_value {
+ None => Err("oops"),
+ Some(value) => Ok(1),
+ });
+}
+++ /dev/null
-// rustfmt-multiline_closure_forces_block: false
-// Option forces multiline closure bodies to be wrapped in a block
-
-fn main() {
- result.and_then(|maybe_value| {
- match maybe_value {
- None => Err("oops"),
- Some(value) => Ok(1),
- }
- });
-}
+++ /dev/null
-// rustfmt-multiline_closure_forces_block: true
-// Option forces multiline closure bodies to be wrapped in a block
-
-fn main() {
- result.and_then(|maybe_value| match maybe_value {
- None => Err("oops"),
- Some(value) => Ok(1),
- });
-}
+++ /dev/null
-// rustfmt-multiline_match_arm_forces_block: false
-// Option forces multiline match arm bodies to be wrapped in a block
-
-fn main() {
- match lorem {
- Lorem::Ipsum => {
- if ipsum {
- println!("dolor");
- }
- }
- Lorem::Dolor => println!("amet"),
- }
-}
+++ /dev/null
-// rustfmt-multiline_match_arm_forces_block: true
-// Option forces multiline match arm bodies to be wrapped in a block
-
-fn main() {
- match lorem {
- Lorem::Ipsum => if ipsum {
- println!("dolor");
- },
- Lorem::Dolor => println!("amet"),
- }
-}
--- /dev/null
+// rustfmt-force_multiline_blocks: false
+// Option forces multiline match arm and closure bodies to be wrapped in a block
+
+fn main() {
+ match lorem {
+ Lorem::Ipsum => if ipsum {
+ println!("dolor");
+ },
+ Lorem::Dolor => println!("amet"),
+ }
+}
+
+fn main() {
+ result.and_then(|maybe_value| match maybe_value {
+ None => Err("oops"),
+ Some(value) => Ok(1),
+ });
+}
--- /dev/null
+// rustfmt-force_multiline_blocks: true
+// Option forces multiline match arm and closure bodies to be wrapped in a block
+
+fn main() {
+ match lorem {
+ Lorem::Ipsum => {
+ if ipsum {
+ println!("dolor");
+ }
+ }
+ Lorem::Dolor => println!("amet"),
+ }
+}
+
+fn main() {
+ result.and_then(|maybe_value| {
+ match maybe_value {
+ None => Err("oops"),
+ Some(value) => Ok(1),
+ }
+ });
+}
+++ /dev/null
-// rustfmt-multiline_closure_forces_block: false
-// Option forces multiline closure bodies to be wrapped in a block
-
-fn main() {
- result.and_then(|maybe_value| match maybe_value {
- None => Err("oops"),
- Some(value) => Ok(1),
- });
-}
+++ /dev/null
-// rustfmt-multiline_closure_forces_block: true
-// Option forces multiline closure bodies to be wrapped in a block
-
-fn main() {
- result.and_then(|maybe_value| {
- match maybe_value {
- None => Err("oops"),
- Some(value) => Ok(1),
- }
- });
-}
+++ /dev/null
-// rustfmt-multiline_match_arm_forces_block: false
-// Option forces multiline match arm bodies to be wrapped in a block
-
-fn main() {
- match lorem {
- Lorem::Ipsum => if ipsum {
- println!("dolor");
- },
- Lorem::Dolor => println!("amet"),
- }
-}
+++ /dev/null
-// rustfmt-multiline_match_arm_forces_block: true
-// Option forces multiline match arm bodies to be wrapped in a block
-
-fn main() {
- match lorem {
- Lorem::Ipsum => {
- if ipsum {
- println!("dolor");
- }
- }
- Lorem::Dolor => println!("amet"),
- }
-}