mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Rollup merge of #73465 - lzutao:spec-char-tostring, r=sfackler
Add specialization of `ToString for char` Closes #73462
This commit is contained in:
commit
d2272d4f60
@ -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")]
|
#[stable(feature = "str_to_string_specialization", since = "1.9.0")]
|
||||||
impl ToString for str {
|
impl ToString for str {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
Loading…
Reference in New Issue
Block a user