I have a function that accepts a struct
fn foo(args: anytype) void {
const ArgsType = TypeOf(args);
const args_type_info = typeInfo(ArgsType);
switch (args_type_info) {
.Struct => { // do work
},
else => @compileError("tuple or struct expected"),
}
I want to pass array elements as a tuple to this function, but the only way I know of is to write all elements manually
const SIZE = 3;
var array = [_]u8{0} ** SIZE;
foo(.{ array[0], array[1], array[2] });
Is there a way to do this automatically in comptime so that if I change SIZE
to 100 I don't have to type all elements by hands?
I know I can extend switch to take .Array
but I'm wondering if I can do it with just .Struct