From 2a29726fcd09fac350e0a8c0d1dd78a8ae6de0ed Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Mon, 2 Mar 2020 21:17:58 -0800 Subject: [PATCH 1/3] Implement From<&mut str> for String --- src/liballoc/string.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index f5afea15d655e..43217ae9364e2 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -2225,6 +2225,14 @@ impl From<&str> for String { } } +#[stable(feature = "???", since = "1.43.0")] +impl From<&mut str> for String { + #[inline] + fn from(s: &mut str) -> String { + s.to_owned() + } +} + #[stable(feature = "from_ref_string", since = "1.35.0")] impl From<&String> for String { #[inline] From 18feaa3fa25f11e403478b562fa1db356b32c818 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Tue, 10 Mar 2020 18:45:08 -0700 Subject: [PATCH 2/3] Add stable feature name --- src/liballoc/string.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 43217ae9364e2..452abe31742f7 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -2225,7 +2225,7 @@ impl From<&str> for String { } } -#[stable(feature = "???", since = "1.43.0")] +#[stable(feature = "from_mut_str_for_string", since = "1.44.0")] impl From<&mut str> for String { #[inline] fn from(s: &mut str) -> String { From 533784d3a247595393ce24c9940945838913a0fe Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Tue, 10 Mar 2020 18:47:19 -0700 Subject: [PATCH 3/3] Add docs for From::<&mut str>::from String impl --- src/liballoc/string.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 452abe31742f7..c8928b4f468cf 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -2227,6 +2227,9 @@ impl From<&str> for String { #[stable(feature = "from_mut_str_for_string", since = "1.44.0")] impl From<&mut str> for String { + /// Converts a `&mut str` into a `String`. + /// + /// The result is allocated on the heap. #[inline] fn from(s: &mut str) -> String { s.to_owned()