From 024c03e81bb576c0063857263b2595ca0980ecf4 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Fri, 3 Aug 2018 22:13:20 +0900 Subject: Use builder pattern for ListFormatting --- src/expr.rs | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'src/expr.rs') 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)) -- cgit 1.4.1-3-g733a5