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]
|
#[inline]
|
||||||
fn is_z(c: char) -> bool {
|
fn is_z(c: char) -> bool {
|
||||||
c == '\0'
|
c == '\0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check whether the character is a line break (`\r` or `\n`).
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_break(c: char) -> bool {
|
fn is_break(c: char) -> bool {
|
||||||
c == '\n' || c == '\r'
|
c == '\n' || c == '\r'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check whether the character is nil or a line break (`\0`, `\r`, `\n`).
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_breakz(c: char) -> bool {
|
fn is_breakz(c: char) -> bool {
|
||||||
is_break(c) || is_z(c)
|
is_break(c) || is_z(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check whether the character is a whitespace (` ` or `\t`).
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_blank(c: char) -> bool {
|
fn is_blank(c: char) -> bool {
|
||||||
c == ' ' || c == '\t'
|
c == ' ' || c == '\t'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check whether the character is nil or a whitespace (`\0`, ` `, `\t`).
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_blankz(c: char) -> bool {
|
fn is_blankz(c: char) -> bool {
|
||||||
is_blank(c) || is_breakz(c)
|
is_blank(c) || is_breakz(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check whether the character is an ascii digit.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_digit(c: char) -> bool {
|
fn is_digit(c: char) -> bool {
|
||||||
c.is_ascii_digit()
|
c.is_ascii_digit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check whether the character is a digit, letter, `_` or `-`.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_alpha(c: char) -> bool {
|
fn is_alpha(c: char) -> bool {
|
||||||
matches!(c, '0'..='9' | 'a'..='z' | 'A'..='Z' | '_' | '-')
|
matches!(c, '0'..='9' | 'a'..='z' | 'A'..='Z' | '_' | '-')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check whether the character is a hexadecimal character (case insensitive).
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_hex(c: char) -> bool {
|
fn is_hex(c: char) -> bool {
|
||||||
c.is_ascii_digit() || ('a'..='f').contains(&c) || ('A'..='F').contains(&c)
|
c.is_ascii_digit() || ('a'..='f').contains(&c) || ('A'..='F').contains(&c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convert the hexadecimal digit to an integer.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_hex(c: char) -> u32 {
|
fn as_hex(c: char) -> u32 {
|
||||||
match c {
|
match c {
|
||||||
|
@ -252,6 +269,8 @@ fn as_hex(c: char) -> u32 {
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check whether the character is a YAML flow character (one of `,[]{}`).
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_flow(c: char) -> bool {
|
fn is_flow(c: char) -> bool {
|
||||||
matches!(c, ',' | '[' | ']' | '{' | '}')
|
matches!(c, ',' | '[' | ']' | '{' | '}')
|
||||||
|
|
Loading…
Reference in a new issue