Skip to content

Commit 1d0378c

Browse files
committed
impl From<char> for String
This allows us to write fn char_to_string() -> String { 'a'.into() } which was not possible before.
1 parent 2935d29 commit 1d0378c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/liballoc/string.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2508,3 +2508,11 @@ impl DoubleEndedIterator for Drain<'_> {
25082508

25092509
#[stable(feature = "fused", since = "1.26.0")]
25102510
impl FusedIterator for Drain<'_> {}
2511+
2512+
#[stable(feature = "from_char_for_string", since = "1.46.0")]
2513+
impl From<char> for String {
2514+
#[inline]
2515+
fn from(c: char) -> Self {
2516+
c.to_string()
2517+
}
2518+
}

0 commit comments

Comments
 (0)