Type Function TagPayload [src]

Deprecated: Use @FieldType(U, @tagName(tag))

Prototype

pub fn TagPayload(comptime U: type, comptime tag: Tag(U)) type

Parameters

U: typetag: Tag(U)

Example

test TagPayload { const Event = union(enum) { Moved: struct { from: i32, to: i32, }, }; const MovedEvent = TagPayload(Event, Event.Moved); const e: Event = .{ .Moved = undefined }; try testing.expect(MovedEvent == @TypeOf(e.Moved)); }

Source

pub fn TagPayload(comptime U: type, comptime tag: Tag(U)) type { return TagPayloadByName(U, @tagName(tag)); }