use crate::{ArabicReshaper, ReshaperConfig};
pub struct ArabicReshaperIter<I>
where
I: Iterator,
{
reshaper: ArabicReshaper,
underlying: I,
}
impl<I> Iterator for ArabicReshaperIter<I>
where
I: Iterator,
I::Item: AsRef<str>,
{
type Item = String;
fn next(&mut self) -> Option<Self::Item> {
self.underlying.next().map(|v| self.reshaper.reshape(v))
}
}
pub trait ArabicReshaperExt: Iterator + Sized
where
Self::Item: AsRef<str>,
{
fn reshape_default(self) -> ArabicReshaperIter<Self> {
ArabicReshaperIter {
reshaper: ArabicReshaper::default(),
underlying: self,
}
}
fn reshape_with_config(self, config: ReshaperConfig) -> ArabicReshaperIter<Self> {
ArabicReshaperIter {
reshaper: ArabicReshaper::new(config),
underlying: self,
}
}
}
impl<I: Iterator> ArabicReshaperExt for I where I::Item: AsRef<str> {}