1use super::*;
2use core::marker::PhantomData;
3
4pub struct FlattenList<I>(PhantomData<I>);
5
6impl<I> Default for FlattenList<I> {
7 fn default() -> Self {
8 FlattenList(PhantomData::default())
9 }
10}
11
12impl<I> FlatMapFn for FlattenList<I>
13where
14 I: ListFn,
15 I::Item: ListFn,
16{
17 type Input = I::Item;
18 type OutputList = I::Item;
19 fn map(&self, input: Self::Input) -> Self::OutputList {
20 input
21 }
22}
23
24pub trait Flatten
25where
26 Self: ListFn,
27 Self::Item: ListFn,
28{
29 fn flatten(self) -> FlatMapList<Self, FlattenList<Self>> {
30 self.flat_map(FlattenList::default())
31 }
32}
33
34impl<S> Flatten for S
35where
36 Self: ListFn,
37 Self::Item: ListFn,
38{
39}