Commit 3a4bb47fed

Meghan Denny <hello@nektro.net>
2025-02-03 23:43:46
std.meta.FieldType: use builtin and deprecate
1 parent 08d661f
Changed files (1)
lib
lib/std/meta.zig
@@ -418,12 +418,9 @@ test fieldInfo {
     try testing.expect(comptime uf.type == u8);
 }
 
+/// Deprecated: use @FieldType
 pub fn FieldType(comptime T: type, comptime field: FieldEnum(T)) type {
-    if (@typeInfo(T) != .@"struct" and @typeInfo(T) != .@"union") {
-        @compileError("Expected struct or union, found '" ++ @typeName(T) ++ "'");
-    }
-
-    return fieldInfo(T, field).type;
+    return @FieldType(T, @tagName(field));
 }
 
 test FieldType {