Skip to content

Commit

Permalink
Use acc.push_str() instead of str::push_str(..)
Browse files Browse the repository at this point in the history
Also added some whitespace to enhance readabilty.
  • Loading branch information
samebchase committed May 11, 2013
1 parent 9ed9e8c commit 7d43b12
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions src/libcore/to_str.rs
Expand Up @@ -125,11 +125,15 @@ impl<'self,A:ToStr> ToStr for &'self [A] {
fn to_str(&self) -> ~str {
let mut acc = ~"[", first = true;
for self.each |elt| {
if first { first = false; }
else { str::push_str(&mut acc, ~", "); }
str::push_str(&mut acc, elt.to_str());
if first {
first = false;
}
else {
acc.push_str(", ");
}
acc.push_str(elt.to_str());
}
str::push_char(&mut acc, ']');
acc.push_char(']');
acc
}
}
Expand All @@ -139,11 +143,15 @@ impl<A:ToStr> ToStr for ~[A] {
fn to_str(&self) -> ~str {
let mut acc = ~"[", first = true;
for self.each |elt| {
if first { first = false; }
else { str::push_str(&mut acc, ~", "); }
str::push_str(&mut acc, elt.to_str());
if first {
first = false;
}
else {
acc.push_str(", ");
}
acc.push_str(elt.to_str());
}
str::push_char(&mut acc, ']');
acc.push_char(']');
acc
}
}
Expand All @@ -153,11 +161,15 @@ impl<A:ToStr> ToStr for @[A] {
fn to_str(&self) -> ~str {
let mut acc = ~"[", first = true;
for self.each |elt| {
if first { first = false; }
else { str::push_str(&mut acc, ~", "); }
str::push_str(&mut acc, elt.to_str());
if first {
first = false;
}
else {
acc.push_str(", ");
}
acc.push_str(elt.to_str());
}
str::push_char(&mut acc, ']');
acc.push_char(']');
acc
}
}
Expand Down

0 comments on commit 7d43b12

Please sign in to comment.