#Is it possible to know wether a type `type` is primive or not ?
1 messages · Page 1 of 1 (latest)
Yeah actually what I wanted to do is a bad idea x)
But still, it'd be cool to know if you can get this info :3
Yes
You can just check for those types in @typeInfo:
fn isPrimitive(comptime T: type) bool {
return switch (@typeInfo(T)) {
.Struct, .Union, .Enum, .Opaque => false,
else => true,
};
}