I though something like the following code would work, but when I try to test it, getTypes returns an empty slice:
pub fn Scheme(comptime name: []const u8) type {
comptime var types: []const type = &[_]type{};
return struct {
pub const scheme_name = name;
pub fn addType(comptime Type: type) void {
if (Type.Scheme != @This()) {
@compileError("some message");
}
types = types ++ &[_]type{Type};
}
pub fn getTypes() []const type {
return types;
}
};
}