Skip to main content

object_rainbow/
assert_impl.rs

1#[macro_export]
2#[doc(hidden)]
3macro_rules! unpack_where {
4    ({$($a:tt)*} {$($tr:tt)*} {$ty:ty} {$($w:tt)*} {}) => {
5        const _: () = {
6            fn _inner<$($a)* X: $($tr)*>() $($w)* {}
7            fn _outer<$($a)*>() $($w)* {
8                _inner::<$($a)* $ty>()
9            }
10        };
11    };
12    ({$($a:tt)*} {$($tr:tt)*} {$ty:ty} {$($w:tt)*} $ww:tt $($www:tt)*) => {
13        $crate::unpack_where!{ {$($a)*} {$($tr)*} {$ty} {$($w)* $ww} $($www)* }
14    };
15}
16
17#[macro_export]
18macro_rules! assert_impl {
19    (impl $(<$($a:ident),*>)? $tr:ident$(<$($tra:ident),*>)? for $ty:ty where $($w:tt)*) => {
20        $crate::unpack_where! { {$($($a,)*)?} {$tr$(<$($tra),*>)?} {$ty} {} where $($w)* }
21    };
22    (impl $(<$($a:ident),*>)? $tr:ident$(<$($tra:ident),*>)? for $ty:ty {}) => {
23        $crate::unpack_where! { {$($($a,)*)?} {$tr$(<$($tra),*>)?} {$ty} {} {} }
24    };
25}
26
27assert_impl!(
28    impl<T> Clone for T where T: Copy {}
29);
30
31assert_impl!(
32    impl Copy for i64 {}
33);