1use alloc::string::String;
2
3use crate::{ArabicReshaper, ReshaperConfig};
4
5pub struct ArabicReshaperIter<I>
8where
9 I: Iterator,
10{
11 reshaper: ArabicReshaper,
12 underlying: I,
13}
14
15impl<I> Iterator for ArabicReshaperIter<I>
16where
17 I: Iterator,
18 I::Item: AsRef<str>,
19{
20 type Item = String;
21
22 fn next(&mut self) -> Option<Self::Item> {
23 self.underlying.next().map(|v| self.reshaper.reshape(v))
24 }
25}
26
27pub trait ArabicReshaperExt: Iterator + Sized
29where
30 Self::Item: AsRef<str>,
31{
32 fn reshape_default(self) -> ArabicReshaperIter<Self> {
34 ArabicReshaperIter {
35 reshaper: ArabicReshaper::default(),
36 underlying: self,
37 }
38 }
39
40 fn reshape_with_config(self, config: ReshaperConfig) -> ArabicReshaperIter<Self> {
42 ArabicReshaperIter {
43 reshaper: ArabicReshaper::new(config),
44 underlying: self,
45 }
46 }
47}
48
49impl<I: Iterator> ArabicReshaperExt for I where I::Item: AsRef<str> {}