Function activeTag [src]

Returns the active tag of a tagged union

Prototype

pub fn activeTag(u: anytype) Tag(@TypeOf(u))

Example

test activeTag { const UE = enum { Int, Float, }; const U = union(UE) { Int: u32, Float: f32, }; var u = U{ .Int = 32 }; try testing.expect(activeTag(u) == UE.Int); u = U{ .Float = 112.9876 }; try testing.expect(activeTag(u) == UE.Float); }

Source

pub fn activeTag(u: anytype) Tag(@TypeOf(u)) { const T = @TypeOf(u); return @as(Tag(T), u); }