Skip to content

Commit

Permalink
Rollup merge of rust-lang#60404 - lo48576:borrow-mut-for-string, r=sf…
Browse files Browse the repository at this point in the history
…ackler

Implement `BorrowMut<str>` for `String`

Closes rust-lang/rfcs#1282.
  • Loading branch information
Centril committed May 1, 2019
2 parents 80da5a5 + a0e112b commit a31ec19
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/liballoc/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a31ec19

Please sign in to comment.