Add some missing Show implementations in libstd

This commit is contained in:
Brendan Zabarauskas
2014-02-13 06:41:34 +11:00
committed by Alex Crichton
parent 8a5b938b3b
commit 957fcb3f54
8 changed files with 193 additions and 20 deletions

View File

@@ -404,6 +404,19 @@ impl fmt::Show for clean::Type {
}
}
impl fmt::Show for clean::Arguments {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for (i, input) in self.values.iter().enumerate() {
if i > 0 { if_ok!(write!(f.buf, ", ")); }
if input.name.len() > 0 {
if_ok!(write!(f.buf, "{}: ", input.name));
}
if_ok!(write!(f.buf, "{}", input.type_));
}
Ok(())
}
}
impl fmt::Show for clean::FnDecl {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "({args}){arrow, select, yes{ -> {ret}} other{}}",
@@ -413,20 +426,6 @@ impl fmt::Show for clean::FnDecl {
}
}
impl fmt::Show for ~[clean::Argument] {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut args = ~"";
for (i, input) in self.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_));
}
f.buf.write(args.as_bytes())
}
}
impl<'a> fmt::Show for Method<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let Method(selfty, d) = *self;
@@ -448,7 +447,7 @@ impl<'a> fmt::Show for Method<'a> {
args.push_str("&amp;self");
}
}
for (i, input) in d.inputs.iter().enumerate() {
for (i, input) in d.inputs.values.iter().enumerate() {
if i > 0 || args.len() > 0 { args.push_str(", "); }
if input.name.len() > 0 {
args.push_str(format!("{}: ", input.name));