I found this solution in the C library called handmade math:
typedef union hmm_vec2 {
struct { float X, Y; };
struct { float U, V; };
struct { float Left, Right; };
struct { float Width, Height; };
float Elements[2];
} hmm_vec2;
In C, this solution allows you to refer to the same memory with different names.
Let’s say you have a variable called my_vec2, you could say my_vec2.x, my_vec2.Height, my_vec2[0]
The use for this is that you don’t have to define different types for the same data-structure but with different field names.
I was wondering if you could do something similar in ZIG. I tried a bit but couldn’t make it work. 🙁
Do you have any suggestions? I would be happy to try.