1
Fork 0

Fix copy warnings in str

This commit is contained in:
Tim Chevalier 2012-10-17 13:47:24 -07:00
parent cf8bded7aa
commit d9f1426e69

View file

@ -207,7 +207,7 @@ pub pure fn connect(v: &[~str], sep: &str) -> ~str {
pub fn repeat(ss: &str, nn: uint) -> ~str { pub fn repeat(ss: &str, nn: uint) -> ~str {
let mut acc = ~""; let mut acc = ~"";
for nn.times { acc += ss; } for nn.times { acc += ss; }
return acc; move acc
} }
/* /*
@ -593,23 +593,23 @@ pub fn split_within(ss: &str, lim: uint) -> ~[~str] {
let mut row : ~str = ~""; let mut row : ~str = ~"";
for words.each |wptr| { for words.each |wptr| {
let word = *wptr; let word = copy *wptr;
// if adding this word to the row would go over the limit, // if adding this word to the row would go over the limit,
// then start a new row // then start a new row
if str::len(row) + str::len(word) + 1 > lim { if row.len() + word.len() + 1 > lim {
rows += [row]; // save previous row rows.push(copy row); // save previous row
row = word; // start a new one row = move word; // start a new one
} else { } else {
if str::len(row) > 0 { row += ~" " } // separate words if row.len() > 0 { row += ~" " } // separate words
row += word; // append to this row row += word; // append to this row
} }
} }
// save the last row // save the last row
if row != ~"" { rows += [row]; } if row != ~"" { rows.push(move row); }
return rows; move rows
} }