casey
casey copied to clipboard
Can this be used in `macro_rules` ?
I want this macro to
macro_rules! enum_with_associated_type {
($($name:ident = $struct:ty, $id:expr ),+) =>{
// ...
}
}
enum_with_asssociated_type!{
MSP_API_VERSION = 1,
}
to expand to this code
impl SomeTrait for MspApiVersion{
fn id()->i16{1}
}
Is that possible with casey
?
Hey @wucke13,
Something like this should work out of the box:
use casey::pascal;
macro_rules! enum_with_associated_type {
($name:ident = $id:expr) => {
pascal!(struct $name {});
impl SomeTrait for pascal!($name) {
fn id() -> i16 { $id }
}
}
}
fn main() {
trait SomeTrait { fn id() -> i16; };
enum_with_associated_type!(
MSP_API_VERSION = 1
);
}
Should this issue be closed?