Coverage Report

Created: 2026-01-13 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/lexical-util-1.0.7/src/ascii.rs
Line
Count
Source
1
//! Utilities for working with ASCII characters.
2
3
/// Determine if a character is a valid ASCII character for float grammar.
4
#[inline(always)]
5
0
pub const fn is_valid_ascii(c: u8) -> bool {
6
    // Below 0x20 is mostly control characters, with no representation.
7
    // 0x7F is a control character, DEL, so don't include it.
8
    // We also want the few visual characters below 0x20:
9
    //  0x09 - Horizontal Tab
10
    //  0x0A - Newline
11
    //  0x0B - Vertical Tab (Deprecated)
12
    //  0x0C - Form Feed (Deprecated)
13
    //  0x0D - Carriage Return
14
0
    (c >= 0x09 && c <= 0x0d) || (c >= 0x20 && c < 0x7F)
15
0
}
16
17
/// Determine if a slice is all valid ASCII characters for float grammar.
18
#[inline(always)]
19
0
pub const fn is_valid_ascii_slice(slc: &[u8]) -> bool {
20
0
    let mut index = 0;
21
0
    while index < slc.len() {
22
0
        if !is_valid_ascii(slc[index]) {
23
0
            return false;
24
0
        }
25
0
        index += 1;
26
    }
27
0
    true
28
0
}
29
30
/// Determine if a character is a valid ASCII letter.
31
#[inline(always)]
32
0
pub const fn is_valid_letter(c: u8) -> bool {
33
0
    (c >= 0x41 && c <= 0x5a) || (c >= 0x61 && c <= 0x7a)
34
0
}
35
36
/// Determine if a slice is all valid ASCII letters.
37
#[inline(always)]
38
0
pub const fn is_valid_letter_slice(slc: &[u8]) -> bool {
39
0
    let mut index = 0;
40
0
    while index < slc.len() {
41
0
        if !is_valid_letter(slc[index]) {
42
0
            return false;
43
0
        }
44
0
        index += 1;
45
    }
46
0
    true
47
0
}