Skip to content

Commit 42ea44b

Browse files
committed
auto merge of #10694 : klutzy/rust/rustdoc-closure, r=alexcrichton
2 parents 68e3292 + 79ed898 commit 42ea44b

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

src/librustdoc/html/format.rs

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -299,22 +299,20 @@ impl fmt::Default for clean::Type {
299299
f.buf.write(s.as_bytes());
300300
}
301301
clean::Closure(ref decl) => {
302-
f.buf.write(match decl.sigil {
303-
ast::BorrowedSigil => "&",
304-
ast::ManagedSigil => "@",
305-
ast::OwnedSigil => "~",
306-
}.as_bytes());
307-
match decl.region {
308-
Some(ref region) => write!(f.buf, "{} ", *region),
309-
None => {}
310-
}
311-
write!(f.buf, "{}{}fn{}",
302+
let region = match decl.region {
303+
Some(ref region) => format!("{} ", *region),
304+
None => ~"",
305+
};
306+
307+
write!(f.buf, "{}{}{arrow, select, yes{ -> {ret}} other{}}",
312308
PuritySpace(decl.purity),
313-
match decl.onceness {
314-
ast::Once => "once ",
315-
ast::Many => "",
309+
match decl.sigil {
310+
ast::OwnedSigil => format!("proc({})", decl.decl.inputs),
311+
ast::BorrowedSigil => format!("{}|{}|", region, decl.decl.inputs),
312+
ast::ManagedSigil => format!("@{}fn({})", region, decl.decl.inputs),
316313
},
317-
decl.decl);
314+
arrow = match decl.decl.output { clean::Unit => "no", _ => "yes" },
315+
ret = decl.decl.output);
318316
// XXX: where are bounds and lifetimes printed?!
319317
}
320318
clean::BareFunction(ref decl) => {
@@ -374,18 +372,24 @@ impl fmt::Default for clean::Type {
374372

375373
impl fmt::Default for clean::FnDecl {
376374
fn fmt(d: &clean::FnDecl, f: &mut fmt::Formatter) {
375+
write!(f.buf, "({args}){arrow, select, yes{ -> {ret}} other{}}",
376+
args = d.inputs,
377+
arrow = match d.output { clean::Unit => "no", _ => "yes" },
378+
ret = d.output);
379+
}
380+
}
381+
382+
impl fmt::Default for ~[clean::Argument] {
383+
fn fmt(inputs: &~[clean::Argument], f: &mut fmt::Formatter) {
377384
let mut args = ~"";
378-
for (i, input) in d.inputs.iter().enumerate() {
385+
for (i, input) in inputs.iter().enumerate() {
379386
if i > 0 { args.push_str(", "); }
380387
if input.name.len() > 0 {
381388
args.push_str(format!("{}: ", input.name));
382389
}
383390
args.push_str(format!("{}", input.type_));
384391
}
385-
write!(f.buf, "({args}){arrow, select, yes{ -> {ret}} other{}}",
386-
args = args,
387-
arrow = match d.output { clean::Unit => "no", _ => "yes" },
388-
ret = d.output);
392+
f.buf.write(args.as_bytes());
389393
}
390394
}
391395

0 commit comments

Comments
 (0)