Back to course

Reflection with @typeInfo

Full Course: Zig Programming From Zero to Hero

Reflection

At comptime, you can inspect any type using @typeInfo. This allows for highly generic code like serializers.

zig const info = @typeInfo(MyStruct); inline for (info.Struct.fields) |field| { std.debug.print("Field name: {s}\n", .{field.name}); }