Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement