diff options
| author | YOSHIOKA Takuma <lo48576@hard-wi.red> | 2019-04-30 15:52:07 +0900 |
|---|---|---|
| committer | YOSHIOKA Takuma <lo48576@hard-wi.red> | 2019-04-30 17:50:38 +0900 |
| commit | a0e112ba52bbf90f958cf51b6fb39970c8a5c8b2 (patch) | |
| tree | 544c8036c885fd7f32d108aa39da4e0805cc1c52 /src/liballoc/str.rs | |
| parent | f843ad60ef5a78d8b4da85c5007d3ecac229f1a8 (diff) | |
| download | rust-a0e112ba52bbf90f958cf51b6fb39970c8a5c8b2.tar.gz rust-a0e112ba52bbf90f958cf51b6fb39970c8a5c8b2.zip | |
Implement `BorrowMut<str>` for `String`
Closes rust-lang/rfcs#1282.
Diffstat (limited to 'src/liballoc/str.rs')
| -rw-r--r-- | src/liballoc/str.rs | 10 |
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; |
