diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-03-15 15:40:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-15 15:40:07 +0100 |
| commit | cc1623267b344684c165a0a6972f2791e2a46728 (patch) | |
| tree | 72b4e159f82afb9a9a30869d143b84a525f131e8 /src/liballoc | |
| parent | d1e943f263fcdb9fa6e375427b79823fc44a6df0 (diff) | |
| parent | 533784d3a247595393ce24c9940945838913a0fe (diff) | |
| download | rust-cc1623267b344684c165a0a6972f2791e2a46728.tar.gz rust-cc1623267b344684c165a0a6972f2791e2a46728.zip | |
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 :)
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/string.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index c95f79472fe..0e48f1548e6 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -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] + fn from(s: &mut str) -> String { + s.to_owned() + } +} + #[stable(feature = "from_ref_string", since = "1.35.0")] impl From<&String> for String { #[inline] |
