Skip to content

Commit fccfc53

Browse files
author
QuietMisdreavus
committed
rustdoc: format non-self arguments for struct methods on their own line
1 parent 9cfd4ef commit fccfc53

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/librustdoc/html/format.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,6 @@ impl<'a> fmt::Display for Method<'a> {
657657
let decl = self.0;
658658
let mut args = String::new();
659659
for (i, input) in decl.inputs.values.iter().enumerate() {
660-
if i > 0 || !args.is_empty() { args.push_str(", "); }
661660
if let Some(selfty) = input.to_self() {
662661
match selfty {
663662
clean::SelfValue => args.push_str("self"),
@@ -672,11 +671,16 @@ impl<'a> fmt::Display for Method<'a> {
672671
}
673672
}
674673
} else {
674+
args.push_str("\n ");
675675
if !input.name.is_empty() {
676676
args.push_str(&format!("{}: ", input.name));
677677
}
678678
args.push_str(&format!("{}", input.type_));
679679
}
680+
if i + 1 < decl.inputs.values.len() { args.push_str(","); }
681+
}
682+
if let Some(None) = decl.inputs.values.iter().last().map(|val| val.to_self()) {
683+
args.push_str("\n");
680684
}
681685
write!(f, "({args}){arrow}", args = args, arrow = decl.output)
682686
}

0 commit comments

Comments
 (0)