diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-07-01 07:42:36 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-01 07:42:36 -0700 |
| commit | b7d13c0604f31791ff13558d76942395c29e3348 (patch) | |
| tree | 6f7428d5058dd0e5d5f03e9d6dc26298f0967da1 /src/liballoc/string.rs | |
| parent | ae79c30d74a52e81687bb35af6481eeeeafaeb84 (diff) | |
| parent | 2cde4932c7e8bd6000378af41029299ccf6eea69 (diff) | |
| download | rust-b7d13c0604f31791ff13558d76942395c29e3348.tar.gz rust-b7d13c0604f31791ff13558d76942395c29e3348.zip | |
Rollup merge of #73466 - matthiaskrgr:char_into_string, r=dtolnay
impl From<char> for String
This allows us to write
````rust
fn char_to_string() -> String {
'a'.into()
}
````
which was not possible before.
Diffstat (limited to 'src/liballoc/string.rs')
| -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 64d9692244d..13ef94dee23 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -2518,3 +2518,11 @@ impl DoubleEndedIterator for Drain<'_> { #[stable(feature = "fused", since = "1.26.0")] impl FusedIterator for Drain<'_> {} + +#[stable(feature = "from_char_for_string", since = "1.46.0")] +impl From<char> for String { + #[inline] + fn from(c: char) -> Self { + c.to_string() + } +} |
