Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
std: Add ToString trait specialization for Cow<'a, str> and String
  • Loading branch information
F001 committed Feb 1, 2017
commit dfcca546fcbdab16b2696550820b0cea5ea7a894
16 changes: 16 additions & 0 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
impl AsRef<str> for String {
#[inline]
Expand Down