formatter: refactor fmt_collection to receive enum for braces type

This commit is contained in:
Sean Hagstrom 2022-05-20 19:00:31 +01:00
parent 5baf1ac8b3
commit 4981f081a7
No known key found for this signature in database
GPG key ID: AA9814E95B301A5C
4 changed files with 56 additions and 17 deletions

View file

@ -1,5 +1,5 @@
use crate::annotation::{Formattable, Newlines, Parens};
use crate::collection::fmt_collection;
use crate::collection::{fmt_collection, Braces};
use crate::def::fmt_def;
use crate::pattern::fmt_pattern;
use crate::spaces::{count_leading_newlines, fmt_comments_only, fmt_spaces, NewlineAt, INDENT};
@ -353,7 +353,7 @@ impl<'a> Formattable for Expr<'a> {
fmt_if(buf, branches, final_else, self.is_multiline(), indent);
}
When(loc_condition, branches) => fmt_when(buf, loc_condition, branches, indent),
List(items) => fmt_collection(buf, indent, '[', ']', *items, Newlines::No),
List(items) => fmt_collection(buf, indent, Braces::Square, *items, Newlines::No),
BinOps(lefts, right) => fmt_bin_ops(buf, lefts, right, false, parens, indent),
UnaryOp(sub_expr, unary_op) => {
buf.indent(indent);