diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-05-16 10:43:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-16 10:43:24 +0200 |
| commit | f08c5bbc850a073cdb60a6bcf29a5052b830b317 (patch) | |
| tree | 57099769db283af19aa821e5f455a5d2d18fc0bf /src/liballoc | |
| parent | 024c25dc7941795b84d76b6371527f31c361a329 (diff) | |
| parent | 08b0aca05e3709766fd7e0e01ec56a8511e4c46b (diff) | |
| download | rust-f08c5bbc850a073cdb60a6bcf29a5052b830b317.tar.gz rust-f08c5bbc850a073cdb60a6bcf29a5052b830b317.zip | |
Rollup merge of #59825 - jsgf:from-ref-string, r=sfackler
string: implement From<&String> for String Allow Strings to be created from borrowed Strings. This is mostly to make things like passing `&String` to an `impl Into<String>` parameter frictionless. Fixes #59827.
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/string.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 63f7769fee5..e74d37c1c2b 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -2189,6 +2189,14 @@ impl From<&str> for String { } } +#[stable(feature = "from_ref_string", since = "1.35.0")] +impl From<&String> for String { + #[inline] + fn from(s: &String) -> String { + s.clone() + } +} + // note: test pulls in libstd, which causes errors here #[cfg(not(test))] #[stable(feature = "string_from_box", since = "1.18.0")] |
