mirror of
https://github.com/ziglang/zig.git
synced 2025-12-14 02:03:08 +00:00
17 lines
310 B
Zig
17 lines
310 B
Zig
const std = @import("std");
|
|
const expect = std.testing.expect;
|
|
|
|
fn BuildType(comptime T: type) type {
|
|
return struct {
|
|
val: union {
|
|
b: T,
|
|
},
|
|
};
|
|
}
|
|
|
|
test {
|
|
const TestStruct = BuildType(u32);
|
|
const c = TestStruct{ .val = .{ .b = 10 } };
|
|
try expect(c.val.b == 10);
|
|
}
|