std: meta.TagPayloadType takes the tag type of the union

This commit is contained in:
daurnimator 2019-12-30 23:09:18 +11:00
parent 17cc511ea4
commit 51943ff432
No known key found for this signature in database
GPG Key ID: 45B429A8F9D9D22A

View File

@ -364,10 +364,8 @@ test "std.meta.activeTag" {
///Given a tagged union type, and an enum, return the type of the union
/// field corresponding to the enum tag.
pub fn TagPayloadType(comptime U: type, tag: var) type {
const Tag = @TypeOf(tag);
pub fn TagPayloadType(comptime U: type, tag: @TagType(U)) type {
testing.expect(trait.is(builtin.TypeId.Union)(U));
testing.expect(trait.is(builtin.TypeId.Enum)(Tag));
const info = @typeInfo(U).Union;