use crossbeam_channel::{Receiver, Sender}; use std::marker; // use std::rc::Rc; // Trait pub trait Session: marker::Sized + marker::Send { type Dual: Session; } // Struct #[derive(Debug)] pub struct Send where T: marker::Send, S: Session, S::Dual: Session, { pub channel: Sender<(T, S::Dual)>, } #[derive(Debug)] pub struct Recv where T: marker::Send, S: Session, { pub channel: Receiver<(T, S)>, } #[derive(Debug)] pub struct End {} // impl impl Session for Send { type Dual = Recv; } impl Session for Recv { type Dual = Send; } impl Session for End { type Dual = End; } // enum enum Test0 { End(End), Branch(Recv), } enum Test1 { End(End), Branch(Recv>), } enum Test2 { End(End), Branch(Recv>), } enum Test3 { End(End), Branch(Send>), } enum Test4 { End(End), Branch(Send>), } enum Test5 { End(End), Branch(Recv>>), } enum Test6 { End(End), Branch(Recv>>), } enum Test7 { End(End), Branch(Recv>>), } enum Test8 { End(End), Branch(Recv>>), } enum Test9 { End(End), Branch(Send>>), } enum Test10 { End(End), Branch(Send>>), } enum Test11 { End(End), Branch(Send>>), } enum Test12 { End(End), Branch(Send>>), } fn main() {}