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
use std::marker::PhantomData;

use super::Pusherator;

pub struct Demux<Func, Nexts, Item> {
    func: Func,
    nexts: Nexts,
    _phantom: PhantomData<fn(Item)>,
}
impl<Func, Nexts, Item> Pusherator for Demux<Func, Nexts, Item>
where
    Func: FnMut(Item, &mut Nexts),
{
    type Item = Item;
    fn give(&mut self, item: Self::Item) {
        (self.func)(item, &mut self.nexts);
    }
}
impl<Func, Nexts, Item> Demux<Func, Nexts, Item>
where
    Func: FnMut(Item, &mut Nexts),
{
    pub fn new(func: Func, nexts: Nexts) -> Self {
        Self {
            func,
            nexts,
            _phantom: PhantomData,
        }
    }
}