1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use super::*;
use core::marker::PhantomData;

pub struct FlattenList<I>(PhantomData<I>);

impl<I> Default for FlattenList<I> {
    fn default() -> Self {
        FlattenList(PhantomData::default())
    }
}

impl<I> FlatMapFn for FlattenList<I>
where
    I: ListFn,
    I::Item: ListFn,
{
    type Input = I::Item;
    type OutputList = I::Item;
    fn map(&self, input: Self::Input) -> Self::OutputList {
        input
    }
}

pub trait Flatten
where
    Self: ListFn,
    Self::Item: ListFn,
{
    fn flatten(self) -> FlatMapList<Self, FlattenList<Self>> {
        self.flat_map(FlattenList::default())
    }
}

impl<S> Flatten for S
where
    Self: ListFn,
    Self::Item: ListFn,
{
}