mirror of
https://github.com/ziglang/zig.git
synced 2025-12-16 03:03:09 +00:00
23 lines
510 B
Zig
23 lines
510 B
Zig
const std = @import("std");
|
|
|
|
fn CreateUnion(comptime T: type) type {
|
|
return @Type(.{
|
|
.Union = .{
|
|
.layout = .Auto,
|
|
.tag_type = null,
|
|
.fields = &[_]std.builtin.Type.UnionField{
|
|
.{
|
|
.name = "field",
|
|
.type = T,
|
|
.alignment = @alignOf(T),
|
|
},
|
|
},
|
|
.decls = &[_]std.builtin.Type.Declaration{},
|
|
},
|
|
});
|
|
}
|
|
|
|
test {
|
|
_ = CreateUnion(struct {});
|
|
}
|