I'm trying to adapt a macro that takes a variable number of type arguments, to a macro that takes a (possibly aliased) tuple type as its last argument:
macro_rules! serialize_individually2 {
($ecs:expr, $ser:expr, $data:expr, ($( $type:ty),*)) => {
$(
SerializeComponents::<NoError, SimpleMarker<SerializeMe>>::serialize(
&( $ecs.read_storage::<$type>(), ),
&$data.0,
&$data.1,
&mut $ser,
)
.unwrap();
)*
};
}
This works on non-aliased tuple types:
serialize_individually2!(ecs, serializer, data, (AreaOfEffect, BlocksTile));
But not on an aliased type:
type TupleComps = (AreaOfEffect, BlocksTile);
serialize_individually2!(ecs, serializer, data, TupleComps);
Is it possible to pattern match and de-alias TupleComps
in a Rust macro?
Original question for reference (more generic, not as well thought out): How to store a list of types using a Rust macro?