Commit 83a4bb6e69

InKryption <59504965+InKryption@users.noreply.github.com>
2021-10-28 17:59:54
Make `std.meta.trait.isContainer` true for opaques
Makes `std.meta.trait.hasFn` work as expected for opaque types with function declarations. Alternative is to add clause directly to `std.meta.trait.hasFn` to account for opaque types.
1 parent eeb8629
Changed files (1)
lib
std
lib/std/meta/trait.zig
@@ -354,7 +354,7 @@ test "std.meta.trait.isConstPtr" {
 
 pub fn isContainer(comptime T: type) bool {
     return switch (@typeInfo(T)) {
-        .Struct, .Union, .Enum => true,
+        .Struct, .Union, .Enum, .Opaque => true,
         else => false,
     };
 }
@@ -368,10 +368,12 @@ test "std.meta.trait.isContainer" {
         A,
         B,
     };
+    const TestOpaque = opaque {};
 
     try testing.expect(isContainer(TestStruct));
     try testing.expect(isContainer(TestUnion));
     try testing.expect(isContainer(TestEnum));
+    try testing.expect(isContainer(TestOpaque));
     try testing.expect(!isContainer(u8));
 }