Skip to content

Commit b7a8f1f

Browse files
committed
Include trailing commas in functions
1 parent 7c52d2d commit b7a8f1f

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/librustdoc/html/format.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -1431,20 +1431,16 @@ impl clean::FnDecl {
14311431
cx: &Context<'_>,
14321432
) -> fmt::Result {
14331433
let amp = if f.alternate() { "&" } else { "&amp;" };
1434-
1434+
14351435
write!(f, "(")?;
14361436
if let Some(n) = line_wrapping_indent
14371437
&& !self.inputs.values.is_empty()
14381438
{
14391439
write!(f, "\n{}", Indent(n + 4))?;
14401440
}
1441+
1442+
let last_input_index = self.inputs.values.len() - 1;
14411443
for (i, input) in self.inputs.values.iter().enumerate() {
1442-
if i > 0 {
1443-
match line_wrapping_indent {
1444-
None => write!(f, ", ")?,
1445-
Some(n) => write!(f, ",\n{}", Indent(n + 4))?,
1446-
};
1447-
}
14481444
if let Some(selfty) = input.to_self() {
14491445
match selfty {
14501446
clean::SelfValue => {
@@ -1477,18 +1473,24 @@ impl clean::FnDecl {
14771473
write!(f, "{}: ", input.name)?;
14781474
input.type_.print(cx).fmt(f)?;
14791475
}
1476+
match line_wrapping_indent {
1477+
None if i == last_input_index => (),
1478+
None => write!(f, ", ")?,
1479+
Some(_n) if i == last_input_index => write!(f, ",\n")?,
1480+
Some(n) => write!(f, ",\n{}", Indent(n + 4))?,
1481+
}
14801482
}
14811483

14821484
if self.c_variadic {
14831485
match line_wrapping_indent {
1484-
None => write!(f, ", ...")?,
1485-
Some(n) => write!(f, "\n{}...", Indent(n + 4))?,
1486+
None => write!(f, "...")?,
1487+
Some(n) => write!(f, "{}...\n", Indent(n + 4))?,
14861488
};
14871489
}
14881490

14891491
match line_wrapping_indent {
14901492
None => write!(f, ")")?,
1491-
Some(n) => write!(f, "\n{})", Indent(n))?,
1493+
Some(n) => write!(f, "{})", Indent(n))?,
14921494
};
14931495

14941496
self.print_output(cx).fmt(f)

0 commit comments

Comments
 (0)