SHARE
TWEET

Untitled

a guest Apr 18th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. trait Widget {}
  2.  
  3. #[derive(Debug)]
  4. struct A;
  5. impl Widget for A {}
  6.  
  7. struct B<C: List>(C);
  8. impl<C: List> Widget for B<C> {}
  9.  
  10. trait List {}
  11. #[derive(Debug)]
  12. struct Cons<A: Widget, B: List>(A, B);
  13. impl<A: Widget, B: List> List for Cons<A, B> {}
  14. #[derive(Debug)]
  15. struct Nil;
  16. impl List for Nil {}
  17.  
  18. macro_rules! children {
  19.     ($head:expr) => { Cons($head, Nil) };
  20.     ($head:expr, $($tail:expr),+) => { Cons($head, children![$($tail),+]) };
  21. }
  22.  
  23. fn main() {
  24.     B(Cons(A, Nil));
  25.     dbg!(children![A, A, A]);
  26. }
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