summaryrefslogtreecommitdiff
path: root/patches
diff options
context:
space:
mode:
authorChris Boesch <chrboesch@noreply.codeberg.org>2026-06-03 18:37:25 +0200
committerChris Boesch <chrboesch@noreply.codeberg.org>2026-06-03 18:37:25 +0200
commitb7ff71cb9e7fba6365e78f00bd75e0d5d507cbfc (patch)
tree6c3f664ff0a900e0d1132f54a1c0410baf389e33 /patches
parentbeeca8d510891a272868f447e8193b0fcee7e2fc (diff)
parenta403436fe8ca2ce7fc53e81365f91ecc6051ef97 (diff)
Merge pull request 'Fix exercises 65, 71, 82 due to the build system update' (#443) from mark2185/exercises:fix-build-update into main
Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/443
Diffstat (limited to 'patches')
-rw-r--r--patches/patches/065_builtins2.patch28
-rw-r--r--patches/patches/071_comptime6.patch16
-rw-r--r--patches/patches/082_anonymous_structs3.patch36
3 files changed, 42 insertions, 38 deletions
diff --git a/patches/patches/065_builtins2.patch b/patches/patches/065_builtins2.patch
index 89fd652..c011646 100644
--- a/patches/patches/065_builtins2.patch
+++ b/patches/patches/065_builtins2.patch
@@ -1,5 +1,5 @@
---- exercises/065_builtins2.zig 2026-02-27 13:10:36
-+++ answers/065_builtins2.zig 2026-02-27 13:10:52
+--- exercises/065_builtins2.zig 2026-06-01 15:33:16.617432671 +0200
++++ answers/065_builtins2.zig 2026-06-01 15:33:31.104018108 +0200
@@ -58,7 +58,7 @@
// Oops! We cannot leave the 'me' and 'myself' fields
// undefined. Please set them here:
@@ -18,22 +18,26 @@
// Now we print a pithy statement about Narcissus.
print("A {s} loves all {s}es. ", .{
-@@ -113,15 +113,15 @@
+@@ -102,16 +102,16 @@
// Please complete these 'if' statements so that the field
// name will not be printed if the field is of type 'void'
// (which is a zero-bit type that takes up no space at all!):
-- if (fields[0].??? != void) {
-+ if (fields[0].type != void) {
- print(" {s}", .{fields[0].name});
+- if (field_???[???] != void) {
+- print(" {s}", .{field_???[???]});
++ if (field_types[0] != void) {
++ print(" {s}", .{field_names[0]});
}
-- if (fields[1].??? != void) {
-+ if (fields[1].type != void) {
- print(" {s}", .{fields[1].name});
+- if (field_???[???] != void) {
+- print(" {s}", .{field_???[???]});
++ if (field_types[1] != void) {
++ print(" {s}", .{field_names[1]});
}
-- if (fields[2].??? != void) {
-+ if (fields[2].type != void) {
- print(" {s}", .{fields[2].name});
+- if (field_???[???] != void) {
+- print(" {s}", .{field_???[???]});
++ if (field_types[2] != void) {
++ print(" {s}", .{field_names[2]});
}
+ // Yuck, look at all that repeated code above! I don't know
diff --git a/patches/patches/071_comptime6.patch b/patches/patches/071_comptime6.patch
index 98fb6e3..b5d2154 100644
--- a/patches/patches/071_comptime6.patch
+++ b/patches/patches/071_comptime6.patch
@@ -1,11 +1,11 @@
---- exercises/071_comptime6.zig 2024-09-02 19:21:50.250454978 +0200
-+++ answers/071_comptime6.zig 2024-09-02 19:21:23.553250563 +0200
-@@ -40,7 +40,7 @@
-
- const fields = @typeInfo(Narcissus).@"struct".fields;
+--- exercises/071_comptime6.zig 2026-06-01 15:35:27.223400223 +0200
++++ answers/071_comptime6.zig 2026-06-01 15:36:35.349728561 +0200
+@@ -41,7 +41,7 @@
+ const field_names = @typeInfo(Narcissus).@"struct".field_names;
+ const field_types = @typeInfo(Narcissus).@"struct".field_types;
- ??? {
-+ inline for (fields) |field| {
- if (field.type != void) {
- print(" {s}", .{field.name});
++ inline for (field_names, field_types) |field_name, field_type| {
+ if (field_type != void) {
+ print(" {s}", .{field_name});
}
diff --git a/patches/patches/082_anonymous_structs3.patch b/patches/patches/082_anonymous_structs3.patch
index 28a6728..972753d 100644
--- a/patches/patches/082_anonymous_structs3.patch
+++ b/patches/patches/082_anonymous_structs3.patch
@@ -1,32 +1,32 @@
---- exercises/082_anonymous_structs3.zig 2026-02-27 13:05:46
-+++ answers/082_anonymous_structs3.zig 2026-02-27 13:07:22
-@@ -82,14 +82,14 @@
- // @typeInfo(Circle).@"struct".fields
+--- exercises/082_anonymous_structs3.zig 2026-06-01 15:59:11.872467805 +0200
++++ answers/082_anonymous_structs3.zig 2026-06-01 15:58:38.004730144 +0200
+@@ -82,17 +82,17 @@
+ // @typeInfo(Circle).@"struct".field_types
//
- // This will be an array of StructFields.
-- const fields = ???;
-+ const fields = @typeInfo(@TypeOf(tuple)).@"struct".fields;
+ // This will be an array of field types.
+- const field_types = ???;
++ const field_types = @typeInfo(@TypeOf(tuple)).@"struct".field_types;
+
+ // This will be an array of field names.
+- const field_names = ???;
++ const field_names = @typeInfo(@TypeOf(tuple)).@"struct".field_names;
// 2. Loop through each field. This must be done at compile
// time.
//
// Hint: remember 'inline' loops?
//
-- for (fields) |field| {
-+ inline for (fields) |field| {
+- for (???, ???) |???, ???| {
++ inline for (field_types, field_names) |field_type, field_name| {
// 3. Print the field's name, type, and value.
//
- // Each 'field' in this loop is one of these:
-@@ -123,9 +123,9 @@
- // for declarations. If it's a value, it looks for data.
- //
+ // You'll need this builtin:
+@@ -116,7 +116,7 @@
print("\"{s}\"({any}):{any} ", .{
-- field.???,
-- field.???,
+ field_name,
+ field_type,
- ???,
-+ field.name,
-+ field.type,
-+ @field(tuple, field.name),
++ @field(tuple, field_name),
});
}
}