zig/test/behavior/bugs/11179.zig
2022-05-27 10:29:24 +03:00

19 lines
442 B
Zig

const std = @import("std");
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,
};
}