orx_iterable/obj_safe/transformations/
fused.rs1use orx_self_or::SoM;
2
3use crate::{
4 obj_safe::{CollectionMutObj, CollectionObj, IterableObj},
5 transformations::{Fused, FusedCol},
6 Collection, CollectionMut, Iterable,
7};
8use std::boxed::Box;
9
10impl<I> IterableObj for Fused<I>
11where
12 I: Iterable,
13{
14 type Item = I::Item;
15
16 fn boxed_iter(&self) -> Box<dyn Iterator<Item = Self::Item> + '_> {
17 Box::new(self.it.iter().fuse())
18 }
19}
20
21impl<'a, I, E> IterableObj for &'a FusedCol<I, E>
24where
25 I: Collection,
26 E: SoM<I>,
27{
28 type Item = &'a I::Item;
29
30 fn boxed_iter(&self) -> Box<dyn Iterator<Item = Self::Item> + '_> {
31 Box::new(self.it.get_ref().iter().fuse())
32 }
33}
34
35impl<I, E> CollectionObj for FusedCol<I, E>
36where
37 I: Collection,
38 E: SoM<I>,
39{
40 type Item = I::Item;
41
42 fn boxed_iter(&self) -> Box<dyn Iterator<Item = &Self::Item> + '_> {
43 Box::new(self.iter())
44 }
45}
46
47impl<I, E> CollectionMutObj for FusedCol<I, E>
48where
49 I: CollectionMut,
50 E: SoM<I>,
51{
52 fn boxed_iter_mut(&mut self) -> Box<dyn Iterator<Item = &mut Self::Item> + '_> {
53 Box::new(self.it.get_mut().iter_mut().fuse())
54 }
55}