about summary refs log tree commit diff
path: root/library/alloc/src
diff options
context:
space:
mode:
authorSquirrel <gilescope@gmail.com>2021-03-08 20:51:27 +0000
committerGitHub <noreply@github.com>2021-03-08 20:51:27 +0000
commit6a58b6af3231505344d450fba99a50c1d5c5ec01 (patch)
treeee13e78b4e3f0bf13d345417cb572d4d91c4c99b /library/alloc/src
parente83378b55f15d3b200111c9de066ea80f51c1b80 (diff)
downloadrust-6a58b6af3231505344d450fba99a50c1d5c5ec01.tar.gz
rust-6a58b6af3231505344d450fba99a50c1d5c5ec01.zip
Update library/alloc/src/string.rs
Co-authored-by: LingMan <LingMan@users.noreply.github.com>
Diffstat (limited to 'library/alloc/src')
-rw-r--r--library/alloc/src/string.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs
index 14bf6eead05..7292ebdaeec 100644
--- a/library/alloc/src/string.rs
+++ b/library/alloc/src/string.rs
@@ -2248,15 +2248,12 @@ impl ToString for i8 {
     #[inline]
     fn to_string(&self) -> String {
         let mut vec = vec![0; 4];
-        let n = *self;
         let mut free = 0;
-        let mut n: u8 = if n.is_negative() {
+        if self.is_negative() {
             vec[free] = b'-';
             free += 1;
-            i8::unsigned_abs(n)
-        } else {
-            n as u8
-        };
+        }
+        let mut n = self.unsigned_abs();
         if n >= 10 {
             if n >= 100 {
                 n -= 100;