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
mod channel;
mod protocol;

pub use channel::Channel;
pub use protocol::{Choice, ChoiceResult, End, Rx, Tx};

pub mod transports {
    mod crossbeam;
    pub use crossbeam::Crossbeam;
}

pub fn pair<A, B, Tr: channel::Transport>(tr: &Tr) -> (Channel<B, Tr>, Channel<A, Tr>) {
    let (ta, ra) = tr.make_channel();
    let (tb, rb) = tr.make_channel();
    (
        Channel::new(tr.clone(), tb, ra),
        Channel::new(tr.clone(), ta, rb),
    )
}

#[macro_export]
macro_rules! rec {
    ($x:ident, $t:ty) => {
        #[derive(Default)]
        struct $x;
        impl $x {
            #[allow(clippy::type_complexity)]
            pub fn rec(self) -> $t {
                Default::default()
            }
        }
    };
}
#[macro_export]
macro_rules! prot {
    ($n:ident, $t:ty) => {
        #[allow(clippy::type_complexity)]
        fn $n() -> $t {
            Default::default()
        }
    };
}