Type Function TagPayloadByName [src]
Deprecated: Use @FieldType(U, tag_name)
Prototype
pub fn TagPayloadByName(comptime U: type, comptime tag_name: []const u8) type
Parameters
U: type
tag_name: []const u8
Source
pub fn TagPayloadByName(comptime U: type, comptime tag_name: []const u8) type {
const info = @typeInfo(U).@"union";
inline for (info.fields) |field_info| {
if (comptime mem.eql(u8, field_info.name, tag_name))
return field_info.type;
}
@compileError("no field '" ++ tag_name ++ "' in union '" ++ @typeName(U) ++ "'");
}