Update library/alloc/src/string.rs
Co-authored-by: LingMan <LingMan@users.noreply.github.com>
This commit is contained in:
parent
e83378b55f
commit
6a58b6af32
1 changed files with 3 additions and 6 deletions
|
@ -2248,15 +2248,12 @@ impl ToString for i8 {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_string(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
let mut vec = vec![0; 4];
|
let mut vec = vec![0; 4];
|
||||||
let n = *self;
|
|
||||||
let mut free = 0;
|
let mut free = 0;
|
||||||
let mut n: u8 = if n.is_negative() {
|
if self.is_negative() {
|
||||||
vec[free] = b'-';
|
vec[free] = b'-';
|
||||||
free += 1;
|
free += 1;
|
||||||
i8::unsigned_abs(n)
|
}
|
||||||
} else {
|
let mut n = self.unsigned_abs();
|
||||||
n as u8
|
|
||||||
};
|
|
||||||
if n >= 10 {
|
if n >= 10 {
|
||||||
if n >= 100 {
|
if n >= 100 {
|
||||||
n -= 100;
|
n -= 100;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue