未验证 提交 cc162326 编写于 作者: M Mazdak Farrokhzad 提交者: GitHub

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 :)
......@@ -2225,6 +2225,17 @@ fn from(s: &str) -> 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()
}
}
#[stable(feature = "from_ref_string", since = "1.35.0")]
impl From<&String> for String {
#[inline]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册