Skip to content

Commit 7d43b12

Browse files
committed
Use acc.push_str() instead of str::push_str(..)
Also added some whitespace to enhance readabilty.
1 parent 9ed9e8c commit 7d43b12

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

src/libcore/to_str.rs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,15 @@ impl<'self,A:ToStr> ToStr for &'self [A] {
125125
fn to_str(&self) -> ~str {
126126
let mut acc = ~"[", first = true;
127127
for self.each |elt| {
128-
if first { first = false; }
129-
else { str::push_str(&mut acc, ~", "); }
130-
str::push_str(&mut acc, elt.to_str());
128+
if first {
129+
first = false;
130+
}
131+
else {
132+
acc.push_str(", ");
133+
}
134+
acc.push_str(elt.to_str());
131135
}
132-
str::push_char(&mut acc, ']');
136+
acc.push_char(']');
133137
acc
134138
}
135139
}
@@ -139,11 +143,15 @@ impl<A:ToStr> ToStr for ~[A] {
139143
fn to_str(&self) -> ~str {
140144
let mut acc = ~"[", first = true;
141145
for self.each |elt| {
142-
if first { first = false; }
143-
else { str::push_str(&mut acc, ~", "); }
144-
str::push_str(&mut acc, elt.to_str());
146+
if first {
147+
first = false;
148+
}
149+
else {
150+
acc.push_str(", ");
151+
}
152+
acc.push_str(elt.to_str());
145153
}
146-
str::push_char(&mut acc, ']');
154+
acc.push_char(']');
147155
acc
148156
}
149157
}
@@ -153,11 +161,15 @@ impl<A:ToStr> ToStr for @[A] {
153161
fn to_str(&self) -> ~str {
154162
let mut acc = ~"[", first = true;
155163
for self.each |elt| {
156-
if first { first = false; }
157-
else { str::push_str(&mut acc, ~", "); }
158-
str::push_str(&mut acc, elt.to_str());
164+
if first {
165+
first = false;
166+
}
167+
else {
168+
acc.push_str(", ");
169+
}
170+
acc.push_str(elt.to_str());
159171
}
160-
str::push_char(&mut acc, ']');
172+
acc.push_char(']');
161173
acc
162174
}
163175
}

0 commit comments

Comments
 (0)