Doccomment is_
series of functions.
This commit is contained in:
parent
c670b32461
commit
1590018312
1 changed files with 19 additions and 0 deletions
|
@ -211,38 +211,55 @@ impl<T: Iterator<Item = char>> Iterator for Scanner<T> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Check whether the character is nil (`\0`).
|
||||
#[inline]
|
||||
fn is_z(c: char) -> bool {
|
||||
c == '\0'
|
||||
}
|
||||
|
||||
/// Check whether the character is a line break (`\r` or `\n`).
|
||||
#[inline]
|
||||
fn is_break(c: char) -> bool {
|
||||
c == '\n' || c == '\r'
|
||||
}
|
||||
|
||||
/// Check whether the character is nil or a line break (`\0`, `\r`, `\n`).
|
||||
#[inline]
|
||||
fn is_breakz(c: char) -> bool {
|
||||
is_break(c) || is_z(c)
|
||||
}
|
||||
|
||||
/// Check whether the character is a whitespace (` ` or `\t`).
|
||||
#[inline]
|
||||
fn is_blank(c: char) -> bool {
|
||||
c == ' ' || c == '\t'
|
||||
}
|
||||
|
||||
/// Check whether the character is nil or a whitespace (`\0`, ` `, `\t`).
|
||||
#[inline]
|
||||
fn is_blankz(c: char) -> bool {
|
||||
is_blank(c) || is_breakz(c)
|
||||
}
|
||||
|
||||
/// Check whether the character is an ascii digit.
|
||||
#[inline]
|
||||
fn is_digit(c: char) -> bool {
|
||||
c.is_ascii_digit()
|
||||
}
|
||||
|
||||
/// Check whether the character is a digit, letter, `_` or `-`.
|
||||
#[inline]
|
||||
fn is_alpha(c: char) -> bool {
|
||||
matches!(c, '0'..='9' | 'a'..='z' | 'A'..='Z' | '_' | '-')
|
||||
}
|
||||
|
||||
/// Check whether the character is a hexadecimal character (case insensitive).
|
||||
#[inline]
|
||||
fn is_hex(c: char) -> bool {
|
||||
c.is_ascii_digit() || ('a'..='f').contains(&c) || ('A'..='F').contains(&c)
|
||||
}
|
||||
|
||||
/// Convert the hexadecimal digit to an integer.
|
||||
#[inline]
|
||||
fn as_hex(c: char) -> u32 {
|
||||
match c {
|
||||
|
@ -252,6 +269,8 @@ fn as_hex(c: char) -> u32 {
|
|||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Check whether the character is a YAML flow character (one of `,[]{}`).
|
||||
#[inline]
|
||||
fn is_flow(c: char) -> bool {
|
||||
matches!(c, ',' | '[' | ']' | '{' | '}')
|
||||
|
|
Loading…
Reference in a new issue