Get the latest tech news
Basic MetaProgramming in Zig
Getting started with Zig's meta programming capabilities by leveraging a few useful functions
The code is hopefully simple enough that not only can we get an initial sense for@typeInfo, but we can also see how hasFn is able to use it, along with@hasDecl, to identify if a struct has a specific function. Newcomers to Zig often ask about behavior similar to std.meta.hasFn or@field, and probably come out of the exchange disappointed to learn about the comptime requirement. Still, taking small steps and using the functions we explored above, plus seeing their implementation, has helped me get more comfortable with comptime in general, and the std.builtin.Type in particular.
Or read this on Hacker News