Add some more common escaping scheme identity checks
This commit is contained in:
parent
28a1e3a3f0
commit
e4def7d21c
|
@ -31,18 +31,28 @@ pub const fn are_all_chars_identity<E: Escape + ~const EscapeMeta>(set: &[char])
|
|||
true
|
||||
}
|
||||
|
||||
const ALPHA_LOWERCASE_CHARS: &[char] = &ascii_chars(b"abcdefghijklmnopqrstuvwxyz");
|
||||
const ALPHA_UPPERCASE_CHARS: &[char] = &ascii_chars(b"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
const DIGIT_CHARS: &[char] = &ascii_chars(b"0123456789");
|
||||
const BOOL_CHARS: &[char] = &ascii_chars(b"truefals");
|
||||
const UINT_CHARS: &[char] = &ascii_chars(b"0123456789");
|
||||
|
||||
impl<E: Escape> CommonIdents<E> {
|
||||
/// True if lowercase ASCII alphabetic characters will never need escaping.
|
||||
pub const ALPHA_LOWERCASE: bool = are_all_chars_identity::<E>(ALPHA_LOWERCASE_CHARS);
|
||||
/// True if uppercase ASCII alphabetic characters will never need escaping.
|
||||
pub const ALPHA_UPPERCASE: bool = are_all_chars_identity::<E>(ALPHA_UPPERCASE_CHARS);
|
||||
/// True if base10 digit characters will never need escaping.
|
||||
pub const DIGITS: bool = are_all_chars_identity::<E>(DIGIT_CHARS);
|
||||
|
||||
/// True if `true` and `false` will never need escaping.
|
||||
pub const BOOLS: bool = are_all_chars_identity::<E>(BOOL_CHARS);
|
||||
/// True if unsigned integers will never need escaping.
|
||||
pub const UINTS: bool = are_all_chars_identity::<E>(UINT_CHARS);
|
||||
pub const UINTS: bool = Self::DIGITS;
|
||||
/// True if signed integers will never need escaping.
|
||||
pub const INTS: bool = Self::UINTS && are_all_chars_identity::<E>(&['-']);
|
||||
pub const INTS: bool = Self::DIGITS && are_all_chars_identity::<E>(&['-']);
|
||||
/// True if floats (using [`ryu`]'s formatting) will never need escaping.
|
||||
pub const FLOATS: bool = Self::INTS && are_all_chars_identity::<E>(&['.', 'e']);
|
||||
pub const FLOATS: bool =
|
||||
Self::DIGITS && are_all_chars_identity::<E>(&['-', '.', 'e']);
|
||||
}
|
||||
|
||||
/// Constant metadata about an impl of [`Escape`].
|
||||
|
|
Loading…
Reference in New Issue