about summary refs log tree commit diff
path: root/src/liballoc/string.rs
diff options
context:
space:
mode:
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 da9afdd2ca3..449e3152d8f 100644
--- a/src/liballoc/string.rs
+++ b/src/liballoc/string.rs
@@ -2240,6 +2240,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> {