Skip to content

Commit

Permalink
impl From<char> for String
Browse files Browse the repository at this point in the history
This allows us to write

fn char_to_string() -> String {
    'a'.into()
}

which was not possible before.
  • Loading branch information
matthiaskrgr committed Jun 18, 2020
1 parent 2935d29 commit 1d0378c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/liballoc/string.rs
Expand Up @@ -2508,3 +2508,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()
}
}

0 comments on commit 1d0378c

Please sign in to comment.