1const std = @import("std");
2const expectEqual = std.testing.expectEqual;
3
4const Number = union {
5 int: i32,
6 float: f64,
7};
8
9test "anonymous union literal syntax" {
10 const i: Number = .{ .int = 42 };
11 const f = makeNumber();
12 try expectEqual(42, i.int);
13 try expectEqual(12.34, f.float);
14}
15
16fn makeNumber() Number {
17 return .{ .float = 12.34 };
18}
19
20// test