Skip to content

Commit 9f4f6cf

Browse files
committed
rollup merge of #19965: japaric/remove-wrong-add
TL;DR I wrongly implemented these two ops, namely `"prefix" + "suffix".to_string()` gives back `"suffixprefix"`. Let's remove them. The correct implementation of these operations (`lhs.clone().push_str(rhs.as_slice())`) is really wasteful, because the lhs has to be cloned and the rhs gets moved/consumed just to be dropped (no buffer reuse). For this reason, I'd prefer to drop the implementation instead of fixing it. This leaves us with the fact that you'll be able to do `String + &str` but not `&str + String`, which may be unexpected. r? @aturon Closes #19952
2 parents e872269 + 1a996f9 commit 9f4f6cf

File tree

2 files changed

+0
-17
lines changed

2 files changed

+0
-17
lines changed

src/libcollections/string.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -886,14 +886,6 @@ impl<'a> Add<&'a str, String> for String {
886886
}
887887
}
888888

889-
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
890-
impl<'a> Add<String, String> for &'a str {
891-
fn add(self, mut other: String) -> String {
892-
other.push_str(self);
893-
other
894-
}
895-
}
896-
897889
impl ops::Slice<uint, str> for String {
898890
#[inline]
899891
fn as_slice_<'a>(&'a self) -> &'a str {

src/libcollections/vec.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,15 +1356,6 @@ impl<'a, T: Clone> Add<&'a [T], Vec<T>> for Vec<T> {
13561356
}
13571357
}
13581358

1359-
#[cfg(not(stage0))] // NOTE(stage0): Remove impl after a snapshot
1360-
impl<'a, T: Clone> Add<Vec<T>, Vec<T>> for &'a [T] {
1361-
#[inline]
1362-
fn add(self, mut rhs: Vec<T>) -> Vec<T> {
1363-
rhs.push_all(self);
1364-
rhs
1365-
}
1366-
}
1367-
13681359
#[unsafe_destructor]
13691360
impl<T> Drop for Vec<T> {
13701361
fn drop(&mut self) {

0 commit comments

Comments
 (0)