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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use crate::{Connector, Pipe, ResetablePipe};
use std::ops::Shr;
pub struct Composed<P>
where
P: Pipe,
{
pipe: P,
}
impl<P> Composed<P>
where
P: Pipe,
{
pub fn new(pipe: P) -> Self {
Composed { pipe }
}
pub fn unwrap(self) -> P {
self.pipe
}
}
impl<P> Pipe for Composed<P>
where
P: Pipe,
{
type InputItem = P::InputItem;
type OutputItem = P::OutputItem;
fn next(&mut self, item: P::InputItem) -> P::OutputItem {
self.pipe.next(item)
}
}
impl<P: ResetablePipe> ResetablePipe for Composed<P>
where
P: ResetablePipe,
{
fn reset(&mut self) {
self.pipe.reset();
}
}
impl<P0, P1> Shr<P1> for Composed<P0>
where
P0: Pipe,
P1: Pipe<InputItem = P0::OutputItem>,
{
type Output = Composed<Connector<P0, P1>>;
fn shr(self, other: P1) -> Self::Output {
Self::Output::new(Connector::new(self.pipe, other))
}
}