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.

directEnumArray

Initializes an array of Data which can be indexed by @intCast(usize, @intFromEnum(enum_value)). If the enum is non-exhaustive, the resulting array will only be large enough to hold all explicit fields. If the enum contains any fields with values that cannot be represented by usize, a compile error is issued. The max_unused_slots parameter limits the total number of items which have no matching enum key (holes in the enum numbering). So for example, if an enum has values 1, 2, 5, and 6, max_unused_slots must be at least 3, to allow unused slots 0, 3, and 4. The init_values parameter must be a struct with field names that match the enum values. If the enum has multiple fields with the same value, the name of the first one must be used.

enums.directEnumArray
pub fn directEnumArray(
    comptime E: type,
    comptime Data: type,
    comptime max_unused_slots: comptime_int,
    init_values: EnumFieldStruct(E, Data, null),
) [directEnumArrayLen(E, max_unused_slots)]Data

File

lib/std/enums.zig:125

Code

pub fn directEnumArray(
    comptime E: type,
    comptime Data: type,
    comptime max_unused_slots: comptime_int,
    init_values: EnumFieldStruct(E, Data, null),
) [directEnumArrayLen(E, max_unused_slots)]Data {
    return directEnumArrayDefault(E, Data, null, max_unused_slots, init_values);
}