Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement From<&mut str> for String #69661

Merged
merged 3 commits into from Mar 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/liballoc/string.rs
Expand Up @@ -2225,6 +2225,17 @@ 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]
LukasKalbertodt marked this conversation as resolved.
Show resolved Hide resolved
fn from(s: &mut str) -> String {
s.to_owned()
}
}

#[stable(feature = "from_ref_string", since = "1.35.0")]
impl From<&String> for String {
#[inline]
Expand Down