aboutsummaryrefslogtreecommitdiff
path: root/lib/std/meta.zig
diff options
context:
space:
mode:
authorCarter Snook <cartersnook04@gmail.com>2025-03-21 12:42:29 -0500
committerLinus Groh <mail@linusgroh.de>2025-03-24 11:13:58 +0000
commit149eace5d563a3326604baf808dabb02edbe7fba (patch)
tree7dfeeb3d7754725659004523003d4cb30b1c4941 /lib/std/meta.zig
parentadee3ee9a2c679069a15bd5476860d45f05b356b (diff)
downloadzig-149eace5d563a3326604baf808dabb02edbe7fba.tar.gz
zig-149eace5d563a3326604baf808dabb02edbe7fba.zip
deprecate O(n) union field type helpers in std.meta
Users should be using @FieldType() instead.
Diffstat (limited to 'lib/std/meta.zig')
-rw-r--r--lib/std/meta.zig5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/std/meta.zig b/lib/std/meta.zig
index f591b5cc2f..c0aef1fb51 100644
--- a/lib/std/meta.zig
+++ b/lib/std/meta.zig
@@ -693,8 +693,10 @@ test activeTag {
try testing.expect(activeTag(u) == UE.Float);
}
+/// Deprecated: Use @FieldType(U, tag_name)
const TagPayloadType = TagPayload;
+/// Deprecated: Use @FieldType(U, tag_name)
pub fn TagPayloadByName(comptime U: type, comptime tag_name: []const u8) type {
const info = @typeInfo(U).@"union";
@@ -706,8 +708,7 @@ pub fn TagPayloadByName(comptime U: type, comptime tag_name: []const u8) type {
@compileError("no field '" ++ tag_name ++ "' in union '" ++ @typeName(U) ++ "'");
}
-/// Given a tagged union type, and an enum, return the type of the union field
-/// corresponding to the enum tag.
+/// Deprecated: Use @FieldType(U, @tagName(tag))
pub fn TagPayload(comptime U: type, comptime tag: Tag(U)) type {
return TagPayloadByName(U, @tagName(tag));
}