Skip to content

Commit e5c5df8

Browse files
committed
Add specialization of ToString for char
1 parent 2935d29 commit e5c5df8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/liballoc/string.rs

+8
Original file line numberDiff line numberDiff line change
@@ -2228,6 +2228,14 @@ impl<T: fmt::Display + ?Sized> ToString for T {
22282228
}
22292229
}
22302230

2231+
#[stable(feature = "char_to_string_specialization", since = "1.46.0")]
2232+
impl ToString for char {
2233+
#[inline]
2234+
fn to_string(&self) -> String {
2235+
String::from(self.encode_utf8(&mut [0; 4]))
2236+
}
2237+
}
2238+
22312239
#[stable(feature = "str_to_string_specialization", since = "1.9.0")]
22322240
impl ToString for str {
22332241
#[inline]

0 commit comments

Comments
 (0)