Skip to content

Commit 6a58b6a

Browse files
gilescopeLingMan
andauthored
Update library/alloc/src/string.rs
Co-authored-by: LingMan <[email protected]>
1 parent e83378b commit 6a58b6a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

library/alloc/src/string.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -2248,15 +2248,12 @@ impl ToString for i8 {
22482248
#[inline]
22492249
fn to_string(&self) -> String {
22502250
let mut vec = vec![0; 4];
2251-
let n = *self;
22522251
let mut free = 0;
2253-
let mut n: u8 = if n.is_negative() {
2252+
if self.is_negative() {
22542253
vec[free] = b'-';
22552254
free += 1;
2256-
i8::unsigned_abs(n)
2257-
} else {
2258-
n as u8
2259-
};
2255+
}
2256+
let mut n = self.unsigned_abs();
22602257
if n >= 10 {
22612258
if n >= 100 {
22622259
n -= 100;

0 commit comments

Comments
 (0)