use utf_types::utf16::Bmp;
use utf_types::utf16::SurrogatePair;
use crate::Utf16Handler;
#[derive(Debug, Clone)]
pub(crate) struct DefaultHandler;
impl DefaultHandler {
pub(crate) fn new() -> Self {
Self {}
}
}
impl Utf16Handler for DefaultHandler {
type Output = char;
#[inline(always)]
fn bmp(&self, bmp: Bmp) -> Self::Output {
bmp.to_char()
}
#[inline(always)]
fn surrogate_pair(&self, surrogate_pair: SurrogatePair) -> Self::Output {
surrogate_pair.to_char()
}
}
crate::macros::named_iterators_from_no_argument_handler!(
DefaultHandler,
char,
,
Utf16Chars,
,
Utf16CharIndices,
);
pub trait Utf16CharsEx {
fn chars(&self) -> Utf16Chars<'_>;
fn char_indices(&self) -> Utf16CharIndices<'_>;
}
impl Utf16CharsEx for [u16] {
#[inline(always)]
fn chars(&self) -> Utf16Chars<'_> {
Utf16Chars::new(self)
}
#[inline(always)]
fn char_indices(&self) -> Utf16CharIndices<'_> {
Utf16CharIndices::new(self)
}
}