diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 7131c1cd881..1b69898e167 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -1019,11 +1019,28 @@ impl AsRef for String { #[stable(feature = "rust1", since = "1.0.0")] impl<'a> From<&'a str> for String { + #[inline] fn from(s: &'a str) -> String { s.to_string() } } +#[stable(feature = "rust1", since = "1.0.0")] +impl<'a> From<&'a str> for Cow<'a, str> { + #[inline] + fn from(s: &'a str) -> Cow<'a, str> { + Cow::Borrowed(s) + } +} + +#[stable(feature = "rust1", since = "1.0.0")] +impl<'a> From for Cow<'a, str> { + #[inline] + fn from(s: String) -> Cow<'a, str> { + Cow::Owned(s) + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Into> for String { fn into(self) -> Vec { @@ -1031,7 +1048,7 @@ impl Into> for String { } } -#[stable(feature = "rust1", since = "1.0.0")] +#[unstable(feature = "into_cow", reason = "may be replaced by `convert::Into`")] impl IntoCow<'static, str> for String { #[inline] fn into_cow(self) -> Cow<'static, str> { @@ -1039,7 +1056,7 @@ impl IntoCow<'static, str> for String { } } -#[stable(feature = "rust1", since = "1.0.0")] +#[unstable(feature = "into_cow", reason = "may be replaced by `convert::Into`")] impl<'a> IntoCow<'a, str> for &'a str { #[inline] fn into_cow(self) -> Cow<'a, str> {