Coverage Report

Created: 2024-09-08 06:35

/rust/registry/src/index.crates.io-6f17d22bba15001f/ryu-1.0.10/src/pretty/exponent.rs
Line
Count
Source (jump to first uncovered line)
1
use crate::digit_table::*;
2
use core::ptr;
3
4
#[cfg_attr(feature = "no-panic", inline)]
5
0
pub unsafe fn write_exponent3(mut k: isize, mut result: *mut u8) -> usize {
6
0
    let sign = k < 0;
7
0
    if sign {
8
0
        *result = b'-';
9
0
        result = result.offset(1);
10
0
        k = -k;
11
0
    }
12
13
0
    debug_assert!(k < 1000);
14
0
    if k >= 100 {
15
0
        *result = b'0' + (k / 100) as u8;
16
0
        k %= 100;
17
0
        let d = DIGIT_TABLE.as_ptr().offset(k * 2);
18
0
        ptr::copy_nonoverlapping(d, result.offset(1), 2);
19
0
        sign as usize + 3
20
0
    } else if k >= 10 {
21
0
        let d = DIGIT_TABLE.as_ptr().offset(k * 2);
22
0
        ptr::copy_nonoverlapping(d, result, 2);
23
0
        sign as usize + 2
24
    } else {
25
0
        *result = b'0' + k as u8;
26
0
        sign as usize + 1
27
    }
28
0
}
29
30
#[cfg_attr(feature = "no-panic", inline)]
31
0
pub unsafe fn write_exponent2(mut k: isize, mut result: *mut u8) -> usize {
32
0
    let sign = k < 0;
33
0
    if sign {
34
0
        *result = b'-';
35
0
        result = result.offset(1);
36
0
        k = -k;
37
0
    }
38
39
0
    debug_assert!(k < 100);
40
0
    if k >= 10 {
41
0
        let d = DIGIT_TABLE.as_ptr().offset(k * 2);
42
0
        ptr::copy_nonoverlapping(d, result, 2);
43
0
        sign as usize + 2
44
    } else {
45
0
        *result = b'0' + k as u8;
46
0
        sign as usize + 1
47
    }
48
0
}