Commit 39915ae086
Changed files (1)
lib
std
meta
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))