Given a type and a name, return the field index according to source order.
Returns null if the field is not found.
pub fn fieldIndex(comptime T: type, comptime name: []const u8) ?comptime_int
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;
}