Skip to content

Commit cc16232

Browse files
authored
Rollup merge of #69661 - lopopolo:string-from-mut-str, r=sfackler
Implement From<&mut str> for String I ran into this missing impl when trying to do `String::from` on the result returned from this API in the `uuid` crate: https://docs.rs/uuid/0.8.1/uuid/adapter/struct.Hyphenated.html#method.encode_lower I wasn't sure what to put in the stability annotation. I'd appreciate some help with that :)
2 parents d1e943f + 533784d commit cc16232

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/liballoc/string.rs

+11
Original file line numberDiff line numberDiff line change
@@ -2225,6 +2225,17 @@ impl From<&str> for String {
22252225
}
22262226
}
22272227

2228+
#[stable(feature = "from_mut_str_for_string", since = "1.44.0")]
2229+
impl From<&mut str> for String {
2230+
/// Converts a `&mut str` into a `String`.
2231+
///
2232+
/// The result is allocated on the heap.
2233+
#[inline]
2234+
fn from(s: &mut str) -> String {
2235+
s.to_owned()
2236+
}
2237+
}
2238+
22282239
#[stable(feature = "from_ref_string", since = "1.35.0")]
22292240
impl From<&String> for String {
22302241
#[inline]

0 commit comments

Comments
 (0)