We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9a9477f commit a69960aCopy full SHA for a69960a
library/alloc/src/string.rs
@@ -2224,6 +2224,25 @@ impl ToString for char {
2224
}
2225
2226
2227
+#[stable(feature = "u8_to_string_specialization", since="1.999.0")]
2228
+impl ToString for u8 {
2229
+ #[inline]
2230
+ fn to_string(&self) -> String {
2231
+ let mut result = String::with_capacity(3);
2232
+ let mut n = *self;
2233
+ if n >= 100 {
2234
+ result.push((b'0' + n / 100) as char);
2235
+ n %= 100;
2236
+ }
2237
+ if !result.is_empty() || n >= 10 {
2238
+ result.push((b'0' + n / 10) as char);
2239
+ n %= 10;
2240
+ };
2241
+ result.push((b'0' + n) as char);
2242
+ result
2243
2244
+}
2245
+
2246
#[stable(feature = "str_to_string_specialization", since = "1.9.0")]
2247
impl ToString for str {
2248
#[inline]
0 commit comments