mirror of
https://github.com/ziglang/zig.git
synced 2026-01-14 11:25:14 +00:00
Changed container and initializer syntax
* <container> { ... } -> <container> . { ... }
* <exrp> { ... } -> <expr> . { ...}
20 lines
385 B
Zig
20 lines
385 B
Zig
const std = @import("std");
|
|
|
|
const B = union(enum).{
|
|
c: C,
|
|
None,
|
|
};
|
|
|
|
const A = struct.{
|
|
b: B,
|
|
};
|
|
|
|
const C = struct.{};
|
|
|
|
test "tagged union with all void fields but a meaningful tag" {
|
|
var a: A = A.{ .b = B.{ .c = C.{} } };
|
|
std.debug.assert(@TagType(B)(a.b) == @TagType(B).c);
|
|
a = A.{ .b = B.None };
|
|
std.debug.assert(@TagType(B)(a.b) == @TagType(B).None);
|
|
}
|