From dfcca546fcbdab16b2696550820b0cea5ea7a894 Mon Sep 17 00:00:00 2001
From: f001 <changchun.fan@qq.com>
Date: Wed, 1 Feb 2017 11:54:36 +0800
Subject: [PATCH] std: Add ToString trait specialization for Cow<'a, str> and
 String

r? @bluss
---
 src/libcollections/string.rs | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs
index b184a8603e6bd..9a985061ebbde 100644
--- a/src/libcollections/string.rs
+++ b/src/libcollections/string.rs
@@ -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]