use crate::{IteratorFused, PhantomData};
mod bytes; mod str;
mod layout;
#[doc = crate::_tags!(text iterator)]
#[doc = crate::_doc_location!("text/char")]
#[must_use]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct CharIter<'a, Source> {
bytes: &'a [u8],
pos: usize,
_source: PhantomData<Source>,
}
impl<'a, Source> CharIter<'a, Source> {
pub(crate) const fn _new(bytes: &'a [u8], pos: usize) -> Self {
Self { bytes, pos, _source: PhantomData }
}
}
impl<'a> Iterator for CharIter<'a, &'a str> {
type Item = char;
#[inline(always)]
fn next(&mut self) -> Option<char> {
self.next_char()
}
fn size_hint(&self) -> (usize, Option<usize>) {
let remaining = self.bytes.len() - self.pos;
(remaining.div_ceil(4), Some(remaining))
}
#[inline(always)]
fn count(self) -> usize {
self.count()
}
}
impl<'a> IteratorFused for CharIter<'a, &'a str> {}
impl<'a> Iterator for CharIter<'a, &'a [u8]> {
type Item = char;
#[inline(always)]
fn next(&mut self) -> Option<char> {
self.next_char()
}
fn size_hint(&self) -> (usize, Option<usize>) {
let remaining = self.bytes.len() - self.pos;
(remaining.div_ceil(4), Some(remaining))
}
#[inline(always)]
fn count(self) -> usize {
self.count()
}
}
impl<'a> IteratorFused for CharIter<'a, &'a [u8]> {}