use crate::{Char, MaybeNiche, char7, char8, char16};
macro_rules! impl_char {
() => {
impl_char![7, 8, 16];
};
($( $bits:literal),+ ) => { $crate::paste! {
$( impl_char!(@[<char $bits>]); )+
}};
(@$name:ident) => {
impl $name {
#[must_use]
pub const fn len_bytes(self) -> usize { Char(self.to_scalar()).len_bytes() }
#[must_use]
pub const fn len_utf8(self) -> usize { self.to_char().len_utf8() }
#[must_use]
pub const fn len_utf16(self) -> usize { self.to_char().len_utf16() }
#[must_use]
pub const fn to_digit(self, radix: u32) -> Option<u32> {
self.to_char().to_digit(radix)
}
#[must_use]
pub const fn is_nul(self) -> bool { self.to_scalar() == 0 }
#[must_use]
pub const fn is_digit(self, radix: u32) -> bool {
if let Some(_) = self.to_digit(radix) { true } else { false }
}
#[must_use]
pub const fn eq(self, other: Self) -> bool {
MaybeNiche(self.0).eq(MaybeNiche(other.0))
}
}
};
}
impl_char!();