zig/test/behavior/bugs/11179.zig
2023-05-11 20:31:52 +02:00

20 lines
478 B
Zig

const std = @import("std");
const builtin = @import("builtin");
const Type = std.builtin.Type;
test "Tuple" {
const fields_list = fields(@TypeOf(.{}));
if (fields_list.len != 0)
@compileError("Argument count mismatch");
}
pub fn fields(comptime T: type) switch (@typeInfo(T)) {
.Struct => []const Type.StructField,
else => unreachable,
} {
return switch (@typeInfo(T)) {
.Struct => |info| info.fields,
else => unreachable,
};
}