Static comptime variable?
Ziggit
Static comptime variable?
Is it possible to preserve some comptime state between comptime function calls? What I am trying to do is to create a logger wrapper that provides IDs to log messages based on their name in the struct. const UnnamedLogger = struct { logger: *Logger, }; fn namedLog(This: type) LogFn(This) { comptime var LastT: type = This; const Static = struct { var i: u8 = 0; }; if (This != LastT) { Static.i = 0; LastT = This; } const info = @typeInfo(This)....
0 comments
No comments yet.