diff --git a/lib/std/meta/trait.zig b/lib/std/meta/trait.zig index 5cea0ecb9a..9e5b080e85 100644 --- a/lib/std/meta/trait.zig +++ b/lib/std/meta/trait.zig @@ -342,6 +342,19 @@ test "std.meta.trait.isContainer" { testing.expect(!isContainer(u8)); } +pub fn isTuple(comptime T: type) bool { + return is(.Struct)(T) and @typeInfo(T).Struct.is_tuple; +} + +test "std.meta.trait.isTuple" { + const t1 = struct {}; + const t2 = .{ .a = 0 }; + const t3 = .{ 1, 2, 3 }; + testing.expect(!isTuple(t1)); + testing.expect(!isTuple(@TypeOf(t2))); + testing.expect(isTuple(@TypeOf(t3))); +} + pub fn hasDecls(comptime T: type, comptime names: anytype) bool { inline for (names) |name| { if (!@hasDecl(T, name))