diff options
| author | John Turner <jturner.usa@gmail.com> | 2025-11-20 23:12:54 +0000 |
|---|---|---|
| committer | John Turner <jturner.usa@gmail.com> | 2025-11-20 23:12:54 +0000 |
| commit | 7fa1e34c22f4c5bfa99925560be9c23bb2d6d670 (patch) | |
| tree | 5f43249b9561e68eed045dc7889e49dffbc5f54b /src/input.rs | |
| parent | 438ade86160efc42ecab98322ceec8ef8d73aacf (diff) | |
| download | mon-7fa1e34c22f4c5bfa99925560be9c23bb2d6d670.tar.gz | |
impl ascii alternatives to alphabetic, numeric and whitespace methods and parsers
Diffstat (limited to 'src/input.rs')
| -rw-r--r-- | src/input.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/input.rs b/src/input.rs index 0857c8c..0b38556 100644 --- a/src/input.rs +++ b/src/input.rs @@ -48,22 +48,44 @@ impl<'a> Input for &'a [u8] { } pub trait Character { + fn is_ascii(&self) -> bool; + fn is_alphabetic(&self) -> bool; + fn is_ascii_alphabetic(&self) -> bool; + fn is_numeric(&self) -> bool; + fn is_ascii_numeric(&self) -> bool { + self.is_ascii() && self.is_numeric() + } + fn is_whitespace(&self) -> bool; + fn is_ascii_whitespace(&self) -> bool; + fn is_alphanumeric(&self) -> bool { self.is_alphabetic() || self.is_numeric() } + + fn is_ascii_alphanumeric(&self) -> bool { + self.is_ascii_alphabetic() || self.is_ascii_numeric() + } } impl Character for char { + fn is_ascii(&self) -> bool { + (*self).is_ascii() + } + fn is_alphabetic(&self) -> bool { (*self).is_ascii_alphabetic() } + fn is_ascii_alphabetic(&self) -> bool { + (*self).is_ascii_alphabetic() + } + fn is_numeric(&self) -> bool { (*self).is_numeric() } @@ -71,6 +93,10 @@ impl Character for char { fn is_whitespace(&self) -> bool { (*self).is_whitespace() } + + fn is_ascii_whitespace(&self) -> bool { + (*self).is_ascii_whitespace() + } } #[derive(Clone)] |
