mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-26 13:01:34 +03:00
be9b42d707
This was already possible in practice by just wrapping a packed union into a packed struct. Now it's also possible without doing that.
15 lines
269 B
Zig
15 lines
269 B
Zig
const std = @import("std");
|
|
const expectEqual = std.testing.expectEqual;
|
|
|
|
test "packed union equality" {
|
|
const U = packed union {
|
|
a: u4,
|
|
b: i4,
|
|
};
|
|
const x: U = .{ .a = 3 };
|
|
const y: U = .{ .b = 3 };
|
|
try expectEqual(x, y);
|
|
}
|
|
|
|
// test
|