From 79ed898f64f45cdcca6eadad3a5ad378fc8ff635 Mon Sep 17 00:00:00 2001 From: klutzy Date: Thu, 28 Nov 2013 02:23:12 +0900 Subject: [PATCH] rustdoc: Use new ||/proc syntax --- src/librustdoc/html/format.rs | 42 +++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 0f490fd960e37..90c317668fc2f 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -299,22 +299,20 @@ impl fmt::Default for clean::Type { f.buf.write(s.as_bytes()); } clean::Closure(ref decl) => { - f.buf.write(match decl.sigil { - ast::BorrowedSigil => "&", - ast::ManagedSigil => "@", - ast::OwnedSigil => "~", - }.as_bytes()); - match decl.region { - Some(ref region) => write!(f.buf, "{} ", *region), - None => {} - } - write!(f.buf, "{}{}fn{}", + let region = match decl.region { + Some(ref region) => format!("{} ", *region), + None => ~"", + }; + + write!(f.buf, "{}{}{arrow, select, yes{ -> {ret}} other{}}", PuritySpace(decl.purity), - match decl.onceness { - ast::Once => "once ", - ast::Many => "", + match decl.sigil { + ast::OwnedSigil => format!("proc({})", decl.decl.inputs), + 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?! } clean::BareFunction(ref decl) => { @@ -374,18 +372,24 @@ impl fmt::Default for clean::Type { impl fmt::Default for clean::FnDecl { 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 = ~""; - for (i, input) in d.inputs.iter().enumerate() { + for (i, input) in inputs.iter().enumerate() { if i > 0 { args.push_str(", "); } if input.name.len() > 0 { args.push_str(format!("{}: ", input.name)); } args.push_str(format!("{}", input.type_)); } - write!(f.buf, "({args}){arrow, select, yes{ -> {ret}} other{}}", - args = args, - arrow = match d.output { clean::Unit => "no", _ => "yes" }, - ret = d.output); + f.buf.write(args.as_bytes()); } }