summaryrefslogtreecommitdiff
path: root/patches
diff options
context:
space:
mode:
Diffstat (limited to 'patches')
-rw-r--r--patches/patches/026_hello2.patch10
-rw-r--r--patches/patches/034_quiz4.patch11
-rw-r--r--patches/patches/106_files.patch25
-rw-r--r--patches/patches/107_files2.patch14
4 files changed, 26 insertions, 34 deletions
diff --git a/patches/patches/026_hello2.patch b/patches/patches/026_hello2.patch
index f99cc67..e35de35 100644
--- a/patches/patches/026_hello2.patch
+++ b/patches/patches/026_hello2.patch
@@ -1,9 +1,9 @@
---- exercises/026_hello2.zig 2025-07-22 09:55:51.337832401 +0200
-+++ answers/026_hello2.zig 2025-07-22 10:00:11.233348058 +0200
-@@ -23,5 +23,5 @@
+--- exercises/026_hello2.zig 2025-12-28 01:51:16.537444980 +0100
++++ answers/026_hello2.zig 2025-12-28 01:51:10.280322328 +0100
+@@ -27,5 +27,5 @@
// to be able to pass it up as a return value of main().
//
// We just learned of a single statement which can accomplish this.
-- stdout.interface.print("Hello world!\n", .{});
-+ try stdout.interface.print("Hello world!\n", .{});
+- stdout.print("Hello world!\n", .{});
++ try stdout.print("Hello world!\n", .{});
}
diff --git a/patches/patches/034_quiz4.patch b/patches/patches/034_quiz4.patch
index 15c95fc..7cf102c 100644
--- a/patches/patches/034_quiz4.patch
+++ b/patches/patches/034_quiz4.patch
@@ -1,15 +1,16 @@
---- exercises/034_quiz4.zig 2025-07-22 09:55:51.337832401 +0200
-+++ answers/034_quiz4.zig 2025-07-22 10:05:08.320323184 +0200
-@@ -9,10 +9,10 @@
+--- exercises/034_quiz4.zig 2025-12-28 14:43:41.087943476 +0100
++++ answers/034_quiz4.zig 2025-12-28 14:42:23.878472164 +0100
+@@ -10,11 +10,11 @@
const NumError = error{IllegalNumber};
-pub fn main() void {
+pub fn main() !void {
- var stdout = std.fs.File.stdout().writer(&.{});
+ var stdout_writer = std.Io.File.stdout().writer(io, &.{});
+ const stdout = &stdout_writer.interface;
- const my_num: u32 = getNumber();
+ const my_num: u32 = try getNumber();
- try stdout.interface.print("my_num={}\n", .{my_num});
+ try stdout.print("my_num={}\n", .{my_num});
}
diff --git a/patches/patches/106_files.patch b/patches/patches/106_files.patch
index 914fe3b..8bff4d6 100644
--- a/patches/patches/106_files.patch
+++ b/patches/patches/106_files.patch
@@ -1,6 +1,6 @@
---- exercises/106_files.zig 2025-08-24 19:23:55.168565003 +0200
-+++ answers/106_files.zig 2025-08-24 19:25:37.745597511 +0200
-@@ -35,7 +35,7 @@
+--- exercises/106_files.zig 2025-12-28 20:38:53.005504479 +0100
++++ answers/106_files.zig 2025-12-28 20:37:42.742154100 +0100
+@@ -39,7 +39,7 @@
// by doing nothing
//
// we want to catch error.PathAlreadyExists and do nothing
@@ -9,21 +9,12 @@
// if there's any other unexpected error we just propagate it through
else => return e,
};
-@@ -44,7 +44,7 @@
- // wait a minute...
- // opening a directory might fail!
- // what should we do here?
-- var output_dir: std.fs.Dir = cwd.openDir("output", .{});
-+ var output_dir: std.fs.Dir = try cwd.openDir("output", .{});
- defer output_dir.close();
-
- // we try to open the file `zigling.txt`,
-@@ -55,7 +55,7 @@
+@@ -59,7 +59,7 @@
// but here we are not yet done writing to the file
// if only there were a keyword in Zig that
// allowed you to "defer" code execution to the end of the scope...
-- file.close();
-+ defer file.close();
+- file.close(io);
++ defer file.close(io);
- // you are not allowed to move these two lines above the file closing line!
- const byte_written = try file.write("It's zigling time!");
+ // you are not allowed to move these lines above the file closing line!
+ var file_writer = file.writer(io, &.{});
diff --git a/patches/patches/107_files2.patch b/patches/patches/107_files2.patch
index 001337d..597c260 100644
--- a/patches/patches/107_files2.patch
+++ b/patches/patches/107_files2.patch
@@ -1,6 +1,6 @@
---- exercises/107_files2.zig 2025-08-24 19:15:17.789371332 +0200
-+++ answers/107_files2.zig 2025-08-24 19:17:58.897538288 +0200
-@@ -33,7 +33,7 @@
+--- exercises/107_files2.zig 2025-12-28 21:17:29.658147954 +0100
++++ answers/107_files2.zig 2025-12-28 21:17:10.585787203 +0100
+@@ -38,7 +38,7 @@
// initialize an array of u8 with all letter 'A'
// we need to pick the size of the array, 64 seems like a good number
// fix the initialization below
@@ -9,12 +9,12 @@
// this should print out : `AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA`
std.debug.print("{s}\n", .{content});
-@@ -41,12 +41,12 @@
+@@ -49,12 +49,12 @@
// can you go here to find a way to read the content?
- // https://ziglang.org/documentation/master/std/#std.fs.File
- // hint: you might find two answers that are both valid in this case
+ // https://ziglang.org/documentation/master/std/#std.Io.Reader
+ // hint: look for a method that reads into a slice
- const bytes_read = zig_read_the_file_or_i_will_fight_you(&content);
-+ const bytes_read = try file.read(&content);
++ const bytes_read = try reader.readSliceShort(&content);
// Woah, too screamy. I know you're excited for zigling time but tone it down a bit.
// Can you print only what we read from the file?