]> git.lizzy.rs Git - rust.git/commitdiff
rustdoc: Use new ||/proc syntax
authorklutzy <klutzytheklutzy@gmail.com>
Wed, 27 Nov 2013 17:23:12 +0000 (02:23 +0900)
committerklutzy <klutzytheklutzy@gmail.com>
Wed, 27 Nov 2013 17:27:04 +0000 (02:27 +0900)
src/librustdoc/html/format.rs

index 0f490fd960e37842aba4cd14532a7af39efb541c..90c317668fc2f8847a957936fb20a347c47a24d1 100644 (file)
@@ -299,22 +299,20 @@ fn fmt(g: &clean::Type, f: &mut fmt::Formatter) {
                 f.buf.write(s.as_bytes());
             }
             clean::Closure(ref decl) => {
-                f.buf.write(match decl.sigil {
-                    ast::BorrowedSigil => "&amp;",
-                    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{ -&gt; {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 @@ fn fmt(g: &clean::Type, f: &mut fmt::Formatter) {
 
 impl fmt::Default for clean::FnDecl {
     fn fmt(d: &clean::FnDecl, f: &mut fmt::Formatter) {
+        write!(f.buf, "({args}){arrow, select, yes{ -&gt; {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{ -&gt; {ret}} other{}}",
-               args = args,
-               arrow = match d.output { clean::Unit => "no", _ => "yes" },
-               ret = d.output);
+        f.buf.write(args.as_bytes());
     }
 }