Skip to content

Commit 3a4bb47

Browse files
nektromlugg
authored andcommitted
std.meta.FieldType: use builtin and deprecate
1 parent 08d661f commit 3a4bb47

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/std/meta.zig

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,12 +418,9 @@ test fieldInfo {
418418
try testing.expect(comptime uf.type == u8);
419419
}
420420

421+
/// Deprecated: use @FieldType
421422
pub fn FieldType(comptime T: type, comptime field: FieldEnum(T)) type {
422-
if (@typeInfo(T) != .@"struct" and @typeInfo(T) != .@"union") {
423-
@compileError("Expected struct or union, found '" ++ @typeName(T) ++ "'");
424-
}
425-
426-
return fieldInfo(T, field).type;
423+
return @FieldType(T, @tagName(field));
427424
}
428425

429426
test FieldType {

0 commit comments

Comments
 (0)