Created
August 25, 2019 05:34
-
-
Save rust-play/5a70f25716373bd7237974fa48eb76bd to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Cast<T>{} | |
macro_rules! cartesian_producs_of_impls { | |
( row[ $($row:ty),* ] col[ $($col:ty),* ] )=>{ | |
cartesian_producs_of_impls!{inner | |
state() | |
row[$($row),*] | |
col[$($col),*] | |
} | |
}; | |
(inner state($($tokens:tt)*) row[] col[ $($col:ty),* ] )=>{ | |
$($tokens)* | |
}; | |
(inner | |
state($($tokens:tt)*) | |
row[ $first_one:ty $(,$rem:ty)* ] | |
col[ $($col:ty),* ] | |
)=>{ | |
cartesian_producs_of_impls!{inner | |
state( | |
$($tokens)* | |
$( impl Cast<$first_one> for $col{} )* | |
) | |
row[$($rem),*] | |
col[$($col),*] | |
} | |
}; | |
} | |
cartesian_producs_of_impls!{ | |
row[u8,u16,u32] | |
col[u8,u16,u32] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment