Skip to content

Commit

Permalink
Rollup merge of #73465 - lzutao:spec-char-tostring, r=sfackler
Browse files Browse the repository at this point in the history
Add specialization of `ToString for char`

Closes #73462
  • Loading branch information
Manishearth committed Jun 19, 2020
2 parents b443a10 + e5c5df8 commit d2272d4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2230,6 +2230,14 @@ impl<T: fmt::Display + ?Sized> ToString for T {
}
}

#[stable(feature = "char_to_string_specialization", since = "1.46.0")]
impl ToString for char {
#[inline]
fn to_string(&self) -> String {
String::from(self.encode_utf8(&mut [0; 4]))
}
}

#[stable(feature = "str_to_string_specialization", since = "1.9.0")]
impl ToString for str {
#[inline]
Expand Down

0 comments on commit d2272d4

Please sign in to comment.