Skip to content

Commit

Permalink
Rollup merge of rust-lang#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 rust-lang#73462
  • Loading branch information
Manishearth authored Jun 18, 2020
2 parents d8f6804 + e5c5df8 commit 67d5f65
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 @@ -2228,6 +2228,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 67d5f65

Please sign in to comment.