diff options
| author | Lzu Tao <taolzu@gmail.com> | 2020-06-18 02:54:35 +0000 |
|---|---|---|
| committer | Lzu Tao <taolzu@gmail.com> | 2020-06-18 02:54:35 +0000 |
| commit | e5c5df8f9c395e340d25ae70f828504148807af4 (patch) | |
| tree | 01dc94ea7582a6443c9b11e4b49a8dd7ad64ec79 /src/liballoc/string.rs | |
| parent | 2935d294ff862fdf96578d0cbbdc289e8e7ba81c (diff) | |
| download | rust-e5c5df8f9c395e340d25ae70f828504148807af4.tar.gz rust-e5c5df8f9c395e340d25ae70f828504148807af4.zip | |
Add specialization of `ToString for char`
Diffstat (limited to 'src/liballoc/string.rs')
| -rw-r--r-- | src/liballoc/string.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 0378ff5362a..fa5757a0b11 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -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] |
