For a given function type, returns a tuple type which fields will correspond to the argument types.
Examples:
ArgsTuple(fn () void) ⇒ tuple { }ArgsTuple(fn (a: u32) u32) ⇒ tuple { u32 }ArgsTuple(fn (a: u32, b: f16) noreturn) ⇒ tuple { u32, f16 }pub fn ArgsTuple(comptime Function: type) type
pub fn ArgsTuple(comptime Function: type) type {
const info = @typeInfo(Function);
if (info != .@"fn")
@compileError("ArgsTuple expects a function type");
const function_info = info.@"fn";
if (function_info.attrs.varargs)
@compileError("Cannot create ArgsTuple for variadic function");
var argument_field_list: [function_info.param_types.len]type = undefined;
inline for (function_info.param_types, 0..) |arg_type, i| {
const T = arg_type orelse @compileError("cannot create ArgsTuple for function with an 'anytype' parameter");
argument_field_list[i] = T;
}
return @Tuple(&argument_field_list);
}