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.

fieldIndex

Given a type and a name, return the field index according to source order. Returns null if the field is not found.

meta.fieldIndex
pub fn fieldIndex(comptime T: type, comptime name: []const u8) ?comptime_int

File

lib/std/meta.zig:719

Code

pub fn fieldIndex(comptime T: type, comptime name: []const u8) ?comptime_int {
    inline for (fieldNames(T), 0..) |field_name, i| {
        if (mem.eql(u8, field_name, name))
            return i;
    }
    return null;
}