magic trailing comma for ExprList (#5365)

This commit is contained in:
David Szotten 2023-06-26 20:59:01 +01:00 committed by GitHub
parent 190bed124f
commit 50a7769d69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 163 additions and 186 deletions

View file

@ -52,23 +52,7 @@ impl FormatNodeRule<ExprList> for FormatExprList {
"A non-empty expression list has dangling comments"
);
let items = format_with(|f| {
let mut iter = elts.iter();
if let Some(first) = iter.next() {
write!(f, [first.format()])?;
}
for item in iter {
write!(f, [text(","), soft_line_break_or_space(), item.format()])?;
}
if !elts.is_empty() {
write!(f, [if_group_breaks(&text(","))])?;
}
Ok(())
});
let items = format_with(|f| f.join_comma_separated().nodes(elts.iter()).finish());
write!(
f,