mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
std.meta.FieldType: use builtin and deprecate
This commit is contained in:
parent
08d661fcfd
commit
3a4bb47fed
@ -418,12 +418,9 @@ test fieldInfo {
|
|||||||
try testing.expect(comptime uf.type == u8);
|
try testing.expect(comptime uf.type == u8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deprecated: use @FieldType
|
||||||
pub fn FieldType(comptime T: type, comptime field: FieldEnum(T)) type {
|
pub fn FieldType(comptime T: type, comptime field: FieldEnum(T)) type {
|
||||||
if (@typeInfo(T) != .@"struct" and @typeInfo(T) != .@"union") {
|
return @FieldType(T, @tagName(field));
|
||||||
@compileError("Expected struct or union, found '" ++ @typeName(T) ++ "'");
|
|
||||||
}
|
|
||||||
|
|
||||||
return fieldInfo(T, field).type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test FieldType {
|
test FieldType {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user