1const std = @import("std");
2const string = []const u8;
3const extras = @import("./lib.zig");
4
5pub fn isContainer(comptime T: type) bool {
6 return switch (@typeInfo(T)) {
7 .@"struct",
8 .@"union",
9 .@"enum",
10 .@"opaque",
11 => true,
12 else => false,
13 };
14}
15
16test {
17 const TestStruct = struct {};
18 const TestUnion = union {
19 a: void,
20 };
21 const TestEnum = enum {
22 A,
23 B,
24 };
25 const TestOpaque = opaque {};
26
27 try std.testing.expect(isContainer(TestStruct));
28 try std.testing.expect(isContainer(TestUnion));
29 try std.testing.expect(isContainer(TestEnum));
30 try std.testing.expect(isContainer(TestOpaque));
31 try std.testing.expect(!isContainer(u8));
32}