rewrite_with_alignment(
fields,
context,
- shape,
+ v_shape,
mk_sp(body_lo, span.hi()),
one_line_width,
)?
let items_str = rewrite_with_alignment(
fields,
context,
- Shape::indented(offset, context.config).sub_width(1)?,
+ Shape::indented(offset.block_indent(context.config), context.config).sub_width(1)?,
mk_sp(body_lo, span.hi()),
one_line_budget,
)?;
} else {
let rest_span = mk_sp(init_last_pos, span.hi());
let rest_str = rewrite_with_alignment(rest, context, shape, rest_span, one_line_width)?;
- Some(
- result
- + spaces
- + "\n"
- + &shape
- .indent
- .block_indent(context.config)
- .to_string(context.config)
- + &rest_str,
- )
+ Some(format!(
+ "{}{}\n{}{}",
+ result,
+ spaces,
+ &shape.indent.to_string(context.config),
+ &rest_str
+ ))
}
}
offset: Indent,
one_line_width: usize,
) -> Option<String> {
- let item_indent = offset.block_indent(context.config);
// 1 = ","
- let item_shape = Shape::indented(item_indent, context.config).sub_width(1)?;
+ let item_shape = Shape::indented(offset, context.config).sub_width(1)?;
let (mut field_prefix_max_width, field_prefix_min_width) =
struct_field_prefix_max_min_width(context, fields, item_shape);
let max_diff = field_prefix_max_width.saturating_sub(field_prefix_min_width);
--- /dev/null
+// rustfmt-struct_field_align_threshold: 50
+
+fn func() {
+ Ok(ServerInformation { name: unwrap_message_string(items.get(0)),
+ vendor: unwrap_message_string(items.get(1)),
+ version: unwrap_message_string(items.get(2)),
+ spec_version: unwrap_message_string(items.get(3)), });
+}
--- /dev/null
+// rustfmt-struct_field_align_threshold: 50
+// rustfmt-indent_style: Visual
+
+fn func() {
+ Ok(ServerInformation { name: unwrap_message_string(items.get(0)),
+ vendor: unwrap_message_string(items.get(1)),
+ version: unwrap_message_string(items.get(2)),
+ spec_version: unwrap_message_string(items.get(3)), });
+}
--- /dev/null
+// rustfmt-struct_field_align_threshold: 50
+
+fn func() {
+ Ok(ServerInformation {
+ name: unwrap_message_string(items.get(0)),
+ vendor: unwrap_message_string(items.get(1)),
+ version: unwrap_message_string(items.get(2)),
+ spec_version: unwrap_message_string(items.get(3)),
+ });
+}
--- /dev/null
+// rustfmt-struct_field_align_threshold: 5
+
+#[derive(Fail, Debug, Clone)]
+pub enum BuildError {
+ LineTooLong { length: usize, limit: usize },
+ DisallowedByte { b: u8, pos: usize },
+ ContainsNewLine { pos: usize },
+}
+
+enum Foo {
+ A { a: usize, bbbbb: () },
+ B { a: (), bbbbb: () },
+}
--- /dev/null
+// rustfmt-struct_field_align_threshold: 50
+// rustfmt-indent_style: Visual
+
+fn func() {
+ Ok(ServerInformation { name: unwrap_message_string(items.get(0)),
+ vendor: unwrap_message_string(items.get(1)),
+ version: unwrap_message_string(items.get(2)),
+ spec_version: unwrap_message_string(items.get(3)), });
+}
+++ /dev/null
-// rustfmt-struct_field_align_threshold: 5
-
-#[derive(Fail, Debug, Clone)]
-pub enum BuildError {
- LineTooLong { length: usize, limit: usize },
- DisallowedByte { b: u8, pos: usize },
- ContainsNewLine { pos: usize },
-}
-
-enum Foo {
- A { a: usize, bbbbb: () },
- B { a: (), bbbbb: () },
-}