An easy way to ensure type matching is to assign them a dummy value within a block that never executes.
macro_rules! check_type_pair {
($a:expr, $b:expr) => {
if false {
let _type_check = if false {$a} else {$b};
}
}
}
Then in the macro you can simply add:
check_type_pair!($arg_1, $arg_2);
See usage example .
source
share