| 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 | pub const fn is_valid_asciirust-analyzer cargo lexical-util 1.0.7 ascii/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 | (c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge().0x09 && c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le().0x0d) || (c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge().0x20 && c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().0x7F) |
| 15 | } |
| 16 | |
| 17 | /// Determine if a slice is all valid ASCII characters for float grammar. |
| 18 | #[inline(always)] |
| 19 | pub const fn is_valid_ascii_slicerust-analyzer cargo lexical-util 1.0.7 ascii/is_valid_ascii_slice().(slc: &[u8]) -> bool { |
| 20 | let mut index = 0; |
| 21 | while index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().slc.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() { |
| 22 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_valid_asciirust-analyzer cargo lexical-util 1.0.7 ascii/is_valid_ascii().(slc[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) { |
| 23 | return false; |
| 24 | } |
| 25 | index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 26 | } |
| 27 | true |
| 28 | } |
| 29 | |
| 30 | /// Determine if a character is a valid ASCII letter. |
| 31 | #[inline(always)] |
| 32 | pub const fn is_valid_letterrust-analyzer cargo lexical-util 1.0.7 ascii/is_valid_letter().(c: u8) -> bool { |
| 33 | (c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge().0x41 && c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le().0x5a) || (c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]ge().0x61 && c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le().0x7a) |
| 34 | } |
| 35 | |
| 36 | /// Determine if a slice is all valid ASCII letters. |
| 37 | #[inline(always)] |
| 38 | pub const fn is_valid_letter_slicerust-analyzer cargo lexical-util 1.0.7 ascii/is_valid_letter_slice().(slc: &[u8]) -> bool { |
| 39 | let mut index = 0; |
| 40 | while index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().slc.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() { |
| 41 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_valid_letterrust-analyzer cargo lexical-util 1.0.7 ascii/is_valid_letter().(slc[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) { |
| 42 | return false; |
| 43 | } |
| 44 | index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 45 | } |
| 46 | true |
| 47 | } |