Rollup merge of #60404 - lo48576:borrow-mut-for-string, r=sfackler
Implement `BorrowMut<str>` for `String` Closes rust-lang/rfcs#1282.
This commit is contained in:
commit
c8c195fb38
1 changed files with 9 additions and 1 deletions
|
@ -28,7 +28,7 @@
|
||||||
// It's cleaner to just turn off the unused_imports warning than to fix them.
|
// It's cleaner to just turn off the unused_imports warning than to fix them.
|
||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
|
|
||||||
use core::borrow::Borrow;
|
use core::borrow::{Borrow, BorrowMut};
|
||||||
use core::str::pattern::{Pattern, Searcher, ReverseSearcher, DoubleEndedSearcher};
|
use core::str::pattern::{Pattern, Searcher, ReverseSearcher, DoubleEndedSearcher};
|
||||||
use core::mem;
|
use core::mem;
|
||||||
use core::ptr;
|
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")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl ToOwned for str {
|
impl ToOwned for str {
|
||||||
type Owned = String;
|
type Owned = String;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue