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.

valuesFromFields

enums.valuesFromFields
pub inline fn valuesFromFields(comptime E: type, comptime field_values: []const comptime_int) []const E

File

lib/std/enums.zig:41

Code

pub inline fn valuesFromFields(comptime E: type, comptime field_values: []const comptime_int) []const E {
    comptime {
        @setEvalBranchQuota(@typeInfo(E).@"enum".field_names.len + eval_branch_quota_cushion);
        var result: [field_values.len]E = undefined;
        for (&result, field_values) |*r, f_value| {
            r.* = @fromBackingInt(@intCast(f_value));
        }
        const final = result;
        return &final;
    }
}