mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
std: Add ToString trait specialization for Cow<'a, str> and String
r? @bluss
This commit is contained in:
parent
24055d0f2a
commit
dfcca546fc
@ -1866,6 +1866,22 @@ impl ToString for str {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "cow_str_to_string_specialization", since = "1.17.0")]
|
||||||
|
impl<'a> ToString for Cow<'a, str> {
|
||||||
|
#[inline]
|
||||||
|
fn to_string(&self) -> String {
|
||||||
|
self[..].to_owned()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "string_to_string_specialization", since = "1.17.0")]
|
||||||
|
impl ToString for String {
|
||||||
|
#[inline]
|
||||||
|
fn to_string(&self) -> String {
|
||||||
|
self.to_owned()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl AsRef<str> for String {
|
impl AsRef<str> for String {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
Loading…
Reference in New Issue
Block a user