use super::category::GeneralCategory;
use super::generated::binary_props;
use super::generated::general_category::general_category as gc_raw;
#[inline]
#[must_use]
pub const fn general_category(c: char) -> GeneralCategory {
gc_raw(c as u32)
}
#[inline]
#[must_use]
pub const fn general_category_u32(cp: u32) -> GeneralCategory {
gc_raw(cp)
}
#[inline]
#[must_use]
pub const fn is_alphabetic(c: char) -> bool {
binary_props::alphabetic(c as u32)
}
#[inline]
#[must_use]
pub const fn is_uppercase(c: char) -> bool {
binary_props::uppercase(c as u32)
}
#[inline]
#[must_use]
pub const fn is_lowercase(c: char) -> bool {
binary_props::lowercase(c as u32)
}
#[inline]
#[must_use]
pub const fn is_whitespace(c: char) -> bool {
binary_props::white_space(c as u32)
}
#[inline]
#[must_use]
pub const fn is_letter(c: char) -> bool {
general_category(c).is_letter()
}
#[inline]
#[must_use]
pub const fn is_mark(c: char) -> bool {
general_category(c).is_mark()
}
#[inline]
#[must_use]
pub const fn is_numeric(c: char) -> bool {
general_category(c).is_number()
}
#[inline]
#[must_use]
pub const fn is_decimal_digit(c: char) -> bool {
matches!(general_category(c), GeneralCategory::DecimalNumber)
}
#[inline]
#[must_use]
pub const fn is_punctuation(c: char) -> bool {
general_category(c).is_punctuation()
}
#[inline]
#[must_use]
pub const fn is_symbol(c: char) -> bool {
general_category(c).is_symbol()
}
#[inline]
#[must_use]
pub const fn is_separator(c: char) -> bool {
general_category(c).is_separator()
}
#[inline]
#[must_use]
pub const fn is_control(c: char) -> bool {
matches!(general_category(c), GeneralCategory::Control)
}
#[inline]
#[must_use]
pub const fn is_format(c: char) -> bool {
matches!(general_category(c), GeneralCategory::Format)
}
#[inline]
#[must_use]
pub const fn is_assigned(c: char) -> bool {
general_category(c).is_assigned()
}
pub trait CharExt {
fn general_category(&self) -> GeneralCategory;
fn is_alphabetic(&self) -> bool;
fn is_uppercase(&self) -> bool;
fn is_lowercase(&self) -> bool;
fn is_whitespace(&self) -> bool;
fn is_letter(&self) -> bool;
fn is_mark(&self) -> bool;
fn is_numeric(&self) -> bool;
fn is_decimal_digit(&self) -> bool;
fn is_punctuation(&self) -> bool;
fn is_symbol(&self) -> bool;
fn is_separator(&self) -> bool;
fn is_control(&self) -> bool;
fn is_format(&self) -> bool;
fn is_assigned(&self) -> bool;
}
impl CharExt for char {
#[inline]
fn general_category(&self) -> GeneralCategory {
general_category(*self)
}
#[inline]
fn is_alphabetic(&self) -> bool {
is_alphabetic(*self)
}
#[inline]
fn is_uppercase(&self) -> bool {
is_uppercase(*self)
}
#[inline]
fn is_lowercase(&self) -> bool {
is_lowercase(*self)
}
#[inline]
fn is_whitespace(&self) -> bool {
is_whitespace(*self)
}
#[inline]
fn is_letter(&self) -> bool {
is_letter(*self)
}
#[inline]
fn is_mark(&self) -> bool {
is_mark(*self)
}
#[inline]
fn is_numeric(&self) -> bool {
is_numeric(*self)
}
#[inline]
fn is_decimal_digit(&self) -> bool {
is_decimal_digit(*self)
}
#[inline]
fn is_punctuation(&self) -> bool {
is_punctuation(*self)
}
#[inline]
fn is_symbol(&self) -> bool {
is_symbol(*self)
}
#[inline]
fn is_separator(&self) -> bool {
is_separator(*self)
}
#[inline]
fn is_control(&self) -> bool {
is_control(*self)
}
#[inline]
fn is_format(&self) -> bool {
is_format(*self)
}
#[inline]
fn is_assigned(&self) -> bool {
is_assigned(*self)
}
}