Skip to content

Commit a0e112b

Browse files
committed
Implement BorrowMut<str> for String
Closes rust-lang/rfcs#1282.
1 parent f843ad6 commit a0e112b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/liballoc/str.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
// It's cleaner to just turn off the unused_imports warning than to fix them.
2929
#![allow(unused_imports)]
3030

31-
use core::borrow::Borrow;
31+
use core::borrow::{Borrow, BorrowMut};
3232
use core::str::pattern::{Pattern, Searcher, ReverseSearcher, DoubleEndedSearcher};
3333
use core::mem;
3434
use core::ptr;
@@ -190,6 +190,14 @@ impl Borrow<str> for String {
190190
}
191191
}
192192

193+
#[stable(feature = "string_borrow_mut", since = "1.36.0")]
194+
impl BorrowMut<str> for String {
195+
#[inline]
196+
fn borrow_mut(&mut self) -> &mut str {
197+
&mut self[..]
198+
}
199+
}
200+
193201
#[stable(feature = "rust1", since = "1.0.0")]
194202
impl ToOwned for str {
195203
type Owned = String;

0 commit comments

Comments
 (0)