| ... | @@ -342,6 +342,19 @@ test "std.meta.trait.isContainer" { | ... | @@ -342,6 +342,19 @@ test "std.meta.trait.isContainer" { |
| 342 | testing.expect(!isContainer(u8)); | 342 | testing.expect(!isContainer(u8)); |
| 343 | } | 343 | } |
| 344 | | 344 | |
| | 345 | pub fn isTuple(comptime T: type) bool { |
| | 346 | return is(.Struct)(T) and @typeInfo(T).Struct.is_tuple; |
| | 347 | } |
| | 348 | |
| | 349 | test "std.meta.trait.isTuple" { |
| | 350 | const t1 = struct {}; |
| | 351 | const t2 = .{ .a = 0 }; |
| | 352 | const t3 = .{ 1, 2, 3 }; |
| | 353 | testing.expect(!isTuple(t1)); |
| | 354 | testing.expect(!isTuple(@TypeOf(t2))); |
| | 355 | testing.expect(isTuple(@TypeOf(t3))); |
| | 356 | } |
| | 357 | |
| 345 | pub fn hasDecls(comptime T: type, comptime names: anytype) bool { | 358 | pub fn hasDecls(comptime T: type, comptime names: anytype) bool { |
| 346 | inline for (names) |name| { | 359 | inline for (names) |name| { |
| 347 | if (!@hasDecl(T, name)) | 360 | if (!@hasDecl(T, name)) |