SHARE
TWEET

Untitled

a guest May 22nd, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. pub trait InputPin {}
  2. pub trait OutputPin {}
  3.  
  4. pub trait IoPin {
  5.     type Input: InputPin + IoPin<Input = Self::Input, Output = Self::Output>;
  6.     type Output: OutputPin + IoPin<Input = Self::Input, Output = Self::Output>;
  7.  
  8.     fn into_input(self) -> Self::Input;
  9.     fn into_output(self) -> Self::Output;
  10. }
  11.  
  12. struct Port<P1, P2> {
  13.     p1: P1,
  14.     p2: P2
  15. }
  16.  
  17. struct Pin;
  18. impl InputPin for Pin {}
  19. impl OutputPin for Pin {}
  20.  
  21. fn main() {
  22.    
  23. }
  24.  
  25. fn some_function<P1, P2>(port: &mut Port<P1, P2>)
  26. where
  27.     P1: IoPin,
  28.     P2: IoPin
  29. {
  30.     let _p1 = port.p1.into_output();
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top