Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Widget {}
- #[derive(Debug)]
- struct A;
- impl Widget for A {}
- struct B<C: List>(C);
- impl<C: List> Widget for B<C> {}
- trait List {}
- #[derive(Debug)]
- struct Cons<A: Widget, B: List>(A, B);
- impl<A: Widget, B: List> List for Cons<A, B> {}
- #[derive(Debug)]
- struct Nil;
- impl List for Nil {}
- macro_rules! children {
- ($head:expr) => { Cons($head, Nil) };
- ($head:expr, $($tail:expr),+) => { Cons($head, children![$($tail),+]) };
- }
- fn main() {
- B(Cons(A, Nil));
- dbg!(children![A, A, A]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement