Function fieldIndex [src]

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

Prototype

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

Parameters

T: typename: []const u8

Source

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