mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
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.
This commit is contained in:
parent
eeb8629bea
commit
83a4bb6e69
@ -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));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user