0PricingLogin
Zig Academy · Lesson

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

  1. Reflecting Fields with @typeInfo
  2. Building Types with @Type
  3. Comptime Validation and @compileError
  4. Generating Code with comptime
← Back to Zig Academy