pusherator/
demux.rs

1use std::marker::PhantomData;
2
3use super::Pusherator;
4
5pub struct Demux<Func, Nexts, Item> {
6    func: Func,
7    nexts: Nexts,
8    _phantom: PhantomData<fn(Item)>,
9}
10impl<Func, Nexts, Item> Pusherator for Demux<Func, Nexts, Item>
11where
12    Func: FnMut(Item, &mut Nexts),
13{
14    type Item = Item;
15    fn give(&mut self, item: Self::Item) {
16        (self.func)(item, &mut self.nexts);
17    }
18}
19impl<Func, Nexts, Item> Demux<Func, Nexts, Item>
20where
21    Func: FnMut(Item, &mut Nexts),
22{
23    pub fn new(func: Func, nexts: Nexts) -> Self {
24        Self {
25            func,
26            nexts,
27            _phantom: PhantomData,
28        }
29    }
30}