about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-05-01 08:29:15 +0200
committerGitHub <noreply@github.com>2019-05-01 08:29:15 +0200
commitc8c195fb38cebe55cb579c0b9ae20bee03e3e664 (patch)
treea9dbdee1c31c12d56363d5c0d073acfa4082d67e /src/liballoc
parent604176cc105fda9deebc053d478f0e89bbf5e61b (diff)
parenta0e112ba52bbf90f958cf51b6fb39970c8a5c8b2 (diff)
downloadrust-c8c195fb38cebe55cb579c0b9ae20bee03e3e664.tar.gz
rust-c8c195fb38cebe55cb579c0b9ae20bee03e3e664.zip
Rollup merge of #60404 - lo48576:borrow-mut-for-string, r=sfackler
Implement `BorrowMut<str>` for `String`

Closes rust-lang/rfcs#1282.
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/str.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs
index e5d4e1c533c..f66ff894ae8 100644
--- a/src/liballoc/str.rs
+++ b/src/liballoc/str.rs
@@ -28,7 +28,7 @@
 // It's cleaner to just turn off the unused_imports warning than to fix them.
 #![allow(unused_imports)]
 
-use core::borrow::Borrow;
+use core::borrow::{Borrow, BorrowMut};
 use core::str::pattern::{Pattern, Searcher, ReverseSearcher, DoubleEndedSearcher};
 use core::mem;
 use core::ptr;
@@ -190,6 +190,14 @@ impl Borrow<str> for String {
     }
 }
 
+#[stable(feature = "string_borrow_mut", since = "1.36.0")]
+impl BorrowMut<str> for String {
+    #[inline]
+    fn borrow_mut(&mut self) -> &mut str {
+        &mut self[..]
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl ToOwned for str {
     type Owned = String;