Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

ArgsTuple

For a given function type, returns a tuple type which fields will correspond to the argument types.

Examples:

meta.ArgsTuple
pub fn ArgsTuple(comptime Function: type) type

File

lib/std/meta.zig:752

Code

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);
}