No, I’m afraid there’s no way to do this because there is no way to dynamically create local variables. See Unpack named tuples (does anyone know how to do it?) - #9 by rdeits and Is it possible to get the fieldnames of a struct inside a macro? - #15 by rdeits for some related discussion.
Related topics
| Topic | Replies | Views | Activity | |
|---|---|---|---|---|
| Is it possible to get the fieldnames of a struct inside a macro? | 18 | 1667 | January 14, 2020 | |
| Metaprogramming - Unpack/pack struct-fields based on symbols | 5 | 1800 | September 3, 2019 | |
| How to copy the fields of a structure as new local variables? | 5 | 152 | February 8, 2025 | |
| Unpack an object by fieldnames into local scope? | 3 | 394 | December 21, 2020 | |
| Macro accessing fields of struct at another module | 1 | 361 | September 28, 2022 |