mirror of
https://github.com/ziglang/zig.git
synced 2025-12-09 15:53:08 +00:00
deprecate O(n) union field type helpers in std.meta
Users should be using @FieldType() instead.
This commit is contained in:
parent
adee3ee9a2
commit
149eace5d5
@ -693,8 +693,10 @@ test activeTag {
|
|||||||
try testing.expect(activeTag(u) == UE.Float);
|
try testing.expect(activeTag(u) == UE.Float);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deprecated: Use @FieldType(U, tag_name)
|
||||||
const TagPayloadType = TagPayload;
|
const TagPayloadType = TagPayload;
|
||||||
|
|
||||||
|
/// Deprecated: Use @FieldType(U, tag_name)
|
||||||
pub fn TagPayloadByName(comptime U: type, comptime tag_name: []const u8) type {
|
pub fn TagPayloadByName(comptime U: type, comptime tag_name: []const u8) type {
|
||||||
const info = @typeInfo(U).@"union";
|
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) ++ "'");
|
@compileError("no field '" ++ tag_name ++ "' in union '" ++ @typeName(U) ++ "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given a tagged union type, and an enum, return the type of the union field
|
/// Deprecated: Use @FieldType(U, @tagName(tag))
|
||||||
/// corresponding to the enum tag.
|
|
||||||
pub fn TagPayload(comptime U: type, comptime tag: Tag(U)) type {
|
pub fn TagPayload(comptime U: type, comptime tag: Tag(U)) type {
|
||||||
return TagPayloadByName(U, @tagName(tag));
|
return TagPayloadByName(U, @tagName(tag));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user