Skip to content

Commit dfcca54

Browse files
committed
std: Add ToString trait specialization for Cow<'a, str> and String
r? @bluss
1 parent 24055d0 commit dfcca54

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/libcollections/string.rs

+16
Original file line numberDiff line numberDiff line change
@@ -1866,6 +1866,22 @@ impl ToString for str {
18661866
}
18671867
}
18681868

1869+
#[stable(feature = "cow_str_to_string_specialization", since = "1.17.0")]
1870+
impl<'a> ToString for Cow<'a, str> {
1871+
#[inline]
1872+
fn to_string(&self) -> String {
1873+
self[..].to_owned()
1874+
}
1875+
}
1876+
1877+
#[stable(feature = "string_to_string_specialization", since = "1.17.0")]
1878+
impl ToString for String {
1879+
#[inline]
1880+
fn to_string(&self) -> String {
1881+
self.to_owned()
1882+
}
1883+
}
1884+
18691885
#[stable(feature = "rust1", since = "1.0.0")]
18701886
impl AsRef<str> for String {
18711887
#[inline]

0 commit comments

Comments
 (0)