Include trailing commas in functions
This commit is contained in:
parent
7c52d2db63
commit
b7a8f1f225
1 changed files with 12 additions and 10 deletions
|
@ -1431,20 +1431,16 @@ impl clean::FnDecl {
|
||||||
cx: &Context<'_>,
|
cx: &Context<'_>,
|
||||||
) -> fmt::Result {
|
) -> fmt::Result {
|
||||||
let amp = if f.alternate() { "&" } else { "&" };
|
let amp = if f.alternate() { "&" } else { "&" };
|
||||||
|
|
||||||
write!(f, "(")?;
|
write!(f, "(")?;
|
||||||
if let Some(n) = line_wrapping_indent
|
if let Some(n) = line_wrapping_indent
|
||||||
&& !self.inputs.values.is_empty()
|
&& !self.inputs.values.is_empty()
|
||||||
{
|
{
|
||||||
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)
|
||||||
|
|
Loading…
Add table
Reference in a new issue