Skip to content

Commit 149eace

Browse files
sno2linusg
authored andcommitted
deprecate O(n) union field type helpers in std.meta
Users should be using @FieldType() instead.
1 parent adee3ee commit 149eace

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/std/meta.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,10 @@ test activeTag {
693693
try testing.expect(activeTag(u) == UE.Float);
694694
}
695695

696+
/// Deprecated: Use @FieldType(U, tag_name)
696697
const TagPayloadType = TagPayload;
697698

699+
/// Deprecated: Use @FieldType(U, tag_name)
698700
pub fn TagPayloadByName(comptime U: type, comptime tag_name: []const u8) type {
699701
const info = @typeInfo(U).@"union";
700702

@@ -706,8 +708,7 @@ pub fn TagPayloadByName(comptime U: type, comptime tag_name: []const u8) type {
706708
@compileError("no field '" ++ tag_name ++ "' in union '" ++ @typeName(U) ++ "'");
707709
}
708710

709-
/// Given a tagged union type, and an enum, return the type of the union field
710-
/// corresponding to the enum tag.
711+
/// Deprecated: Use @FieldType(U, @tagName(tag))
711712
pub fn TagPayload(comptime U: type, comptime tag: Tag(U)) type {
712713
return TagPayloadByName(U, @tagName(tag));
713714
}

0 commit comments

Comments
 (0)