macro_rules! typemap {
{ $struct:ident =>
$( $num:tt $ty:ty ),* $(,)?
} => { ... };
}
Expand description
A really bad way to genericize struct fields.
This abomination lets you create a struct with one field per type,
accessible through as_ref()
. Internally this is just a tuple, so there is
the caveat that you need to manually specify the index of each “field”.
typemap! { SetOfSomeObjects =>
0 SomeBindGroupLayoutOne,
1 SomeOtherBindGroupTwo,
2 EvenABuffer,
3 AndHeresAPipeline,
4 f32,
}
let set_of_some_objects = SetOfSomeObjects(
SomeBindGroupLayoutOne::new(),
...
);
let buffer: EvenABuffer = set_of_some_objects.as_ref();
let pipeline: AndHeresAPipeline = set_of_some_objects.as_ref();