diff options
| author | George Burton <burtonageo@gmail.com> | 2018-04-22 22:57:52 +0100 |
|---|---|---|
| committer | George Burton <burtonageo@gmail.com> | 2018-04-22 22:57:52 +0100 |
| commit | 1133a149f1bd89bbc9303e3514a6bc20c3a5fc8b (patch) | |
| tree | 80cff074923f350ef99554dab8f3e9fc6269b334 /src/liballoc/string.rs | |
| parent | ff48277add047928dcd19d64ffe93c46b0612a4d (diff) | |
| download | rust-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.rs | 8 |
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> { |
