3 ms·
`@bitCast` addresses this use case: const std = @import("std"); const expect = std.testing.expect; test { const group1: P = .{ .a = true,
by AndyKelley 4y ago
`@bitCast` addresses this use case:
const std = @import("std");
const expect = std.testing.expect;
test {
const group1: P = .{ .a = true, .b = true };
const group2: P = .{ .c = true };
const group3 = @bitCast(P, @bitCast(u4, group1) | @bitCast(u4, group2));
try expect(group3.a);
try expect(group3.b);
try expect(group3.c);
try expect(!group3.d);
}
const P = packed struct {
a: bool = false,
b: bool = false,
c: bool = false,
d: bool = false,
};