about summary refs log tree commit diff
path: root/src/liballoc/string.rs
diff options
context:
space:
mode:
authorGeorge Burton <burtonageo@gmail.com>2018-04-22 22:57:52 +0100
committerGeorge Burton <burtonageo@gmail.com>2018-04-22 22:57:52 +0100
commit1133a149f1bd89bbc9303e3514a6bc20c3a5fc8b (patch)
tree80cff074923f350ef99554dab8f3e9fc6269b334 /src/liballoc/string.rs
parentff48277add047928dcd19d64ffe93c46b0612a4d (diff)
downloadrust-1133a149f1bd89bbc9303e3514a6bc20c3a5fc8b.tar.gz
rust-1133a149f1bd89bbc9303e3514a6bc20c3a5fc8b.zip
Implement From for more types on Cow
Diffstat (limited to 'src/liballoc/string.rs')
-rw-r--r--src/liballoc/string.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs
index 2f84d5f7f86..5f684361fdc 100644
--- a/src/liballoc/string.rs
+++ b/src/liballoc/string.rs
@@ -2239,6 +2239,14 @@ impl<'a> From<String> for Cow<'a, str> {
     }
 }
 
+#[stable(feature = "cow_from_string_ref", since = "1.28.0")]
+impl<'a> From<&'a String> for Cow<'a, str> {
+    #[inline]
+    fn from(s: &'a String) -> Cow<'a, str> {
+        Cow::Borrowed(s.as_str())
+    }
+}
+
 #[stable(feature = "cow_str_from_iter", since = "1.12.0")]
 impl<'a> FromIterator<char> for Cow<'a, str> {
     fn from_iter<I: IntoIterator<Item = char>>(it: I) -> Cow<'a, str> {