From d9f1426e69410f0eda9b4c1b2e87042a8bbda41d Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Wed, 17 Oct 2012 13:47:24 -0700 Subject: [PATCH] Fix copy warnings in str --- src/libcore/str.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libcore/str.rs b/src/libcore/str.rs index da1defc38b1..abd9621cf0f 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -207,7 +207,7 @@ pub fn push_str(lhs: &mut ~str, rhs: &str) { pub fn repeat(ss: &str, nn: uint) -> ~str { let mut acc = ~""; 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 = ~""; for words.each |wptr| { - let word = *wptr; + let word = copy *wptr; // if adding this word to the row would go over the limit, // then start a new row - if str::len(row) + str::len(word) + 1 > lim { - rows += [row]; // save previous row - row = word; // start a new one + if row.len() + word.len() + 1 > lim { + rows.push(copy row); // save previous row + row = move word; // start a new one } else { - if str::len(row) > 0 { row += ~" " } // separate words + if row.len() > 0 { row += ~" " } // separate words row += word; // append to this row } } // save the last row - if row != ~"" { rows += [row]; } + if row != ~"" { rows.push(move row); } - return rows; + move rows } -- GitLab