about summary refs log tree commit diff
path: root/src/expr.rs
diff options
context:
space:
mode:
authorSeiichi Uchida <seiichi.uchida@dena.com>2018-08-03 22:13:20 +0900
committerSeiichi Uchida <seiichi.uchida@dena.com>2018-08-03 22:13:20 +0900
commit024c03e81bb576c0063857263b2595ca0980ecf4 (patch)
tree31b8987f4c41b16af0397360677d696340cb83cd /src/expr.rs
parent3d7d04d3e2adf3053349301141d7f4695bc3b581 (diff)
Use builder pattern for ListFormatting
Diffstat (limited to 'src/expr.rs')
-rw-r--r--src/expr.rs30
1 files changed, 8 insertions, 22 deletions
diff --git a/src/expr.rs b/src/expr.rs
index 72cf618dca5..0f4474d7c0f 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -1197,17 +1197,11 @@ pub fn rewrite_multiple_patterns(
             shape.width,
         )
     };
-    let fmt = ListFormatting {
-        tactic,
-        separator: " |",
-        trailing_separator: SeparatorTactic::Never,
-        separator_place: context.config.binop_separator(),
-        shape,
-        ends_with_newline: false,
-        preserve_newline: false,
-        nested: false,
-        config: context.config,
-    };
+    let fmt = ListFormatting::new(shape, context.config)
+        .tactic(tactic)
+        .separator(" |")
+        .separator_place(context.config.binop_separator())
+        .ends_with_newline(false);
     write_list(&items, &fmt)
 }
 
@@ -1760,17 +1754,9 @@ where
         Separator::Comma,
         nested_shape.width,
     );
-    let fmt = ListFormatting {
-        tactic,
-        separator: ",",
-        trailing_separator: SeparatorTactic::Never,
-        separator_place: SeparatorPlace::Back,
-        shape,
-        ends_with_newline: false,
-        preserve_newline: false,
-        nested: false,
-        config: context.config,
-    };
+    let fmt = ListFormatting::new(shape, context.config)
+        .tactic(tactic)
+        .ends_with_newline(false);
     let list_str = write_list(&item_vec, &fmt)?;
 
     Some(format!("({})", list_str))