From 6a09df9079279297c5f68c0a1214a17e8193cd6a Mon Sep 17 00:00:00 2001 From: Jack O'Connor Date: Sun, 17 Jul 2016 11:31:44 -0400 Subject: [PATCH] implement AddAssign for String --- src/libcollections/string.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index eedf4c2c11f..688f0576042 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -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> for String { type Output = str; -- 2.44.0