Reflecting Fields with @typeInfo
Inspect a type's structure at compile time.
Look Inside Any Type
Zig lets your code examine its own types while it compiles. The built-in @typeInfo hands you the full structure of a type as data. 🔎
It Returns a Type.Info Value
@typeInfo takes a type and returns a std.builtin.Type value. That value is a tagged union describing exactly what kind of type you passed.
const info = @typeInfo(u32);All lessons in this course
- Reflecting Fields with @typeInfo
- Building Types with @Type
- Comptime Validation and @compileError
- Generating Code with comptime