rustdoc: Use new ||/proc syntax

This commit is contained in:
klutzy 2013-11-28 02:23:12 +09:00
parent 17af6f7d0c
commit 79ed898f64

View file

@ -299,22 +299,20 @@ impl fmt::Default for clean::Type {
f.buf.write(s.as_bytes()); f.buf.write(s.as_bytes());
} }
clean::Closure(ref decl) => { clean::Closure(ref decl) => {
f.buf.write(match decl.sigil { let region = match decl.region {
ast::BorrowedSigil => "&", Some(ref region) => format!("{} ", *region),
ast::ManagedSigil => "@", None => ~"",
ast::OwnedSigil => "~", };
}.as_bytes());
match decl.region { write!(f.buf, "{}{}{arrow, select, yes{ -> {ret}} other{}}",
Some(ref region) => write!(f.buf, "{} ", *region),
None => {}
}
write!(f.buf, "{}{}fn{}",
PuritySpace(decl.purity), PuritySpace(decl.purity),
match decl.onceness { match decl.sigil {
ast::Once => "once ", ast::OwnedSigil => format!("proc({})", decl.decl.inputs),
ast::Many => "", ast::BorrowedSigil => format!("{}|{}|", region, decl.decl.inputs),
ast::ManagedSigil => format!("@{}fn({})", region, decl.decl.inputs),
}, },
decl.decl); arrow = match decl.decl.output { clean::Unit => "no", _ => "yes" },
ret = decl.decl.output);
// XXX: where are bounds and lifetimes printed?! // XXX: where are bounds and lifetimes printed?!
} }
clean::BareFunction(ref decl) => { clean::BareFunction(ref decl) => {
@ -374,18 +372,24 @@ impl fmt::Default for clean::Type {
impl fmt::Default for clean::FnDecl { impl fmt::Default for clean::FnDecl {
fn fmt(d: &clean::FnDecl, f: &mut fmt::Formatter) { fn fmt(d: &clean::FnDecl, f: &mut fmt::Formatter) {
write!(f.buf, "({args}){arrow, select, yes{ -> {ret}} other{}}",
args = d.inputs,
arrow = match d.output { clean::Unit => "no", _ => "yes" },
ret = d.output);
}
}
impl fmt::Default for ~[clean::Argument] {
fn fmt(inputs: &~[clean::Argument], f: &mut fmt::Formatter) {
let mut args = ~""; let mut args = ~"";
for (i, input) in d.inputs.iter().enumerate() { for (i, input) in inputs.iter().enumerate() {
if i > 0 { args.push_str(", "); } if i > 0 { args.push_str(", "); }
if input.name.len() > 0 { if input.name.len() > 0 {
args.push_str(format!("{}: ", input.name)); args.push_str(format!("{}: ", input.name));
} }
args.push_str(format!("{}", input.type_)); args.push_str(format!("{}", input.type_));
} }
write!(f.buf, "({args}){arrow, select, yes{ -> {ret}} other{}}", f.buf.write(args.as_bytes());
args = args,
arrow = match d.output { clean::Unit => "no", _ => "yes" },
ret = d.output);
} }
} }