Include trailing commas in functions

This commit is contained in:
Sergi-Ferrez 2024-06-04 02:11:37 +02:00
parent 7c52d2db63
commit b7a8f1f225

View file

@ -1438,13 +1438,9 @@ impl clean::FnDecl {
{ {
write!(f, "\n{}", Indent(n + 4))?; write!(f, "\n{}", Indent(n + 4))?;
} }
let last_input_index = self.inputs.values.len() - 1;
for (i, input) in self.inputs.values.iter().enumerate() { for (i, input) in self.inputs.values.iter().enumerate() {
if i > 0 {
match line_wrapping_indent {
None => write!(f, ", ")?,
Some(n) => write!(f, ",\n{}", Indent(n + 4))?,
};
}
if let Some(selfty) = input.to_self() { if let Some(selfty) = input.to_self() {
match selfty { match selfty {
clean::SelfValue => { clean::SelfValue => {
@ -1477,18 +1473,24 @@ impl clean::FnDecl {
write!(f, "{}: ", input.name)?; write!(f, "{}: ", input.name)?;
input.type_.print(cx).fmt(f)?; input.type_.print(cx).fmt(f)?;
} }
match line_wrapping_indent {
None if i == last_input_index => (),
None => write!(f, ", ")?,
Some(_n) if i == last_input_index => write!(f, ",\n")?,
Some(n) => write!(f, ",\n{}", Indent(n + 4))?,
}
} }
if self.c_variadic { if self.c_variadic {
match line_wrapping_indent { match line_wrapping_indent {
None => write!(f, ", ...")?, None => write!(f, "...")?,
Some(n) => write!(f, "\n{}...", Indent(n + 4))?, Some(n) => write!(f, "{}...\n", Indent(n + 4))?,
}; };
} }
match line_wrapping_indent { match line_wrapping_indent {
None => write!(f, ")")?, None => write!(f, ")")?,
Some(n) => write!(f, "\n{})", Indent(n))?, Some(n) => write!(f, "{})", Indent(n))?,
}; };
self.print_output(cx).fmt(f) self.print_output(cx).fmt(f)