summaryrefslogtreecommitdiff
path: root/exercises/082_anonymous_structs3.zig
diff options
context:
space:
mode:
authorLuka Markušić <markusicluka@gmail.com>2026-06-01 15:41:22 +0200
committerLuka Markušić <markusicluka@gmail.com>2026-06-01 16:00:27 +0200
commit3b865a0c175e7537aeea389fb5f05c6e3489a685 (patch)
treef46e36f8574008406e8d6deeda4191662c2c1558 /exercises/082_anonymous_structs3.zig
parent63c798637cbb8b73ac0348933cc8dc42bfa9810a (diff)
Fix 082_anonymous_structs3.zig because of new build system
Diffstat (limited to 'exercises/082_anonymous_structs3.zig')
-rw-r--r--exercises/082_anonymous_structs3.zig31
1 files changed, 11 insertions, 20 deletions
diff --git a/exercises/082_anonymous_structs3.zig b/exercises/082_anonymous_structs3.zig
index c13774f..e99c826 100644
--- a/exercises/082_anonymous_structs3.zig
+++ b/exercises/082_anonymous_structs3.zig
@@ -74,36 +74,27 @@ fn printTuple(tuple: anytype) void {
// @typeInfo() - takes a type, returns a TypeInfo union
// with fields specific to that type.
//
- // The list of a struct type's fields can be found in
- // TypeInfo's @"struct".fields.
+ // The list of a struct type's field types can be found in
+ // TypeInfo's @"struct".field_types.
//
// Example:
//
- // @typeInfo(Circle).@"struct".fields
+ // @typeInfo(Circle).@"struct".field_types
//
- // This will be an array of StructFields.
- const fields = ???;
+ // This will be an array of field types.
+ const field_types = ???;
+
+ // This will be an array of field names.
+ const field_names = ???;
// 2. Loop through each field. This must be done at compile
// time.
//
// Hint: remember 'inline' loops?
//
- for (fields) |field| {
+ for (???, ???) |???, ???| {
// 3. Print the field's name, type, and value.
//
- // Each 'field' in this loop is one of these:
- //
- // pub const StructField = struct {
- // name: [:0]const u8,
- // type: type,
- // default_value_ptr: ?*const anyopaque,
- // is_comptime: bool,
- // alignment: comptime_int,
- // };
- //
- // Note we will learn about 'anyopaque' type later
- //
// You'll need this builtin:
//
// @field(lhs: anytype, comptime field_name: []const u8)
@@ -123,8 +114,8 @@ fn printTuple(tuple: anytype) void {
// for declarations. If it's a value, it looks for data.
//
print("\"{s}\"({any}):{any} ", .{
- field.???,
- field.???,
+ field_name,
+ field_type,
???,
});
}