Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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 standard library. Public Type Function

ArgsTuple

Public Type Function
std.meta.ArgsTuple
pub fn ArgsTuple(comptime Function: type) type

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 }

File

meta.zig:762
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
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);
}