From d1b49f353eaa7358a4041a3090e87f49dc0a4bf6 Mon Sep 17 00:00:00 2001 From: Chris Boesch Date: Fri, 20 Sep 2024 12:10:55 +0200 Subject: [PATCH] Minor improvements. --- build.zig | 4 +--- exercises/108_labeled_switch.zig | 6 +++--- patches/patches/108_labeled_switch.patch | 12 ++++++------ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/build.zig b/build.zig index 8041e07..a1f6029 100644 --- a/build.zig +++ b/build.zig @@ -1199,9 +1199,7 @@ const exercises = [_]Exercise{ }, .{ .main_file = "108_labeled_switch.zig", - .output = - \\The pull request has been merged - , + .output = "The pull request has been merged.", }, .{ .main_file = "999_the_end.zig", diff --git a/exercises/108_labeled_switch.zig b/exercises/108_labeled_switch.zig index 0748d9d..88cb196 100644 --- a/exercises/108_labeled_switch.zig +++ b/exercises/108_labeled_switch.zig @@ -63,15 +63,15 @@ const PullRequestState = enum(u8) { pub fn main() void { // Oh no, your pull request keeps being rejected, // how would you fix it? - pr: switch (@as(PullRequestState, PullRequestState.Draft)) { + pr: switch (PullRequestState.Draft) { PullRequestState.Draft => continue :pr PullRequestState.InReview, PullRequestState.InReview => continue :pr PullRequestState.Rejected, PullRequestState.Approved => continue :pr PullRequestState.Merged, PullRequestState.Rejected => { - std.debug.print("The pull request has been rejected", .{}); + std.debug.print("The pull request has been rejected.\n", .{}); return; }, PullRequestState.Merged => break, // Would you know where to break to? } - std.debug.print("The pull request has been merged", .{}); + std.debug.print("The pull request has been merged.\n", .{}); } diff --git a/patches/patches/108_labeled_switch.patch b/patches/patches/108_labeled_switch.patch index 467540c..fa9dd67 100644 --- a/patches/patches/108_labeled_switch.patch +++ b/patches/patches/108_labeled_switch.patch @@ -1,18 +1,18 @@ ---- a/exercises/108_labeled_switch.zig -+++ b/exercises/108_labeled_switch.zig -@@ -65,13 +65,13 @@ pub fn main() void { +--- exercises/108_labeled_switch.zig 2024-09-20 12:09:24.370066539 +0200 ++++ answers/108_labeled_switch.zig 2024-09-20 12:09:06.499711739 +0200 +@@ -65,13 +65,13 @@ // how would you fix it? - pr: switch (@as(PullRequestState, PullRequestState.Draft)) { + pr: switch (PullRequestState.Draft) { PullRequestState.Draft => continue :pr PullRequestState.InReview, - PullRequestState.InReview => continue :pr PullRequestState.Rejected, + PullRequestState.InReview => continue :pr PullRequestState.Approved, PullRequestState.Approved => continue :pr PullRequestState.Merged, PullRequestState.Rejected => { - std.debug.print("The pull request has been rejected", .{}); + std.debug.print("The pull request has been rejected.\n", .{}); return; }, - PullRequestState.Merged => break, // Would you know where to break to? + PullRequestState.Merged => break :pr, // Would you know where to break to? } - std.debug.print("The pull request has been merged", .{}); + std.debug.print("The pull request has been merged.\n", .{}); }