]> git.lizzy.rs Git - rust.git/commitdiff
implement AddAssign for String
authorJack O'Connor <oconnor663@gmail.com>
Sun, 17 Jul 2016 15:31:44 +0000 (11:31 -0400)
committerJack O'Connor <oconnor663@gmail.com>
Sun, 17 Jul 2016 19:30:21 +0000 (15:30 -0400)
src/libcollections/string.rs

index eedf4c2c11f34fcf32808df3805259efa9990513..688f057604251056b4dd656f138a128f620e1577 100644 (file)
@@ -59,7 +59,7 @@
 use core::hash;
 use core::iter::FromIterator;
 use core::mem;
-use core::ops::{self, Add, Index, IndexMut};
+use core::ops::{self, Add, AddAssign, Index, IndexMut};
 use core::ptr;
 use core::str::pattern::Pattern;
 use rustc_unicode::char::{decode_utf16, REPLACEMENT_CHARACTER};
@@ -1559,6 +1559,14 @@ fn add(mut self, other: &str) -> String {
     }
 }
 
+#[stable(feature = "rust1", since = "1.11.0")]
+impl<'a> AddAssign<&'a str> for String {
+    #[inline]
+    fn add_assign(&mut self, other: &str) {
+        self.push_str(other);
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl ops::Index<ops::Range<usize>> for String {
     type Output = str;