Merge pull request 'Minor improvements.' (#163) from patch_lbl_sw into main

Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/163
This commit is contained in:
Chris Boesch 2024-09-20 10:19:26 +00:00
commit 67c824118e
3 changed files with 10 additions and 12 deletions

View file

@ -1199,9 +1199,7 @@ const exercises = [_]Exercise{
}, },
.{ .{
.main_file = "108_labeled_switch.zig", .main_file = "108_labeled_switch.zig",
.output = .output = "The pull request has been merged.",
\\The pull request has been merged
,
}, },
.{ .{
.main_file = "999_the_end.zig", .main_file = "999_the_end.zig",

View file

@ -63,15 +63,15 @@ const PullRequestState = enum(u8) {
pub fn main() void { pub fn main() void {
// Oh no, your pull request keeps being rejected, // Oh no, your pull request keeps being rejected,
// how would you fix it? // how would you fix it?
pr: switch (@as(PullRequestState, PullRequestState.Draft)) { pr: switch (PullRequestState.Draft) {
PullRequestState.Draft => continue :pr PullRequestState.InReview, PullRequestState.Draft => continue :pr PullRequestState.InReview,
PullRequestState.InReview => continue :pr PullRequestState.Rejected, PullRequestState.InReview => continue :pr PullRequestState.Rejected,
PullRequestState.Approved => continue :pr PullRequestState.Merged, PullRequestState.Approved => continue :pr PullRequestState.Merged,
PullRequestState.Rejected => { PullRequestState.Rejected => {
std.debug.print("The pull request has been rejected", .{}); std.debug.print("The pull request has been rejected.\n", .{});
return; return;
}, },
PullRequestState.Merged => break, // Would you know where to break to? 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", .{});
} }

View file

@ -1,18 +1,18 @@
--- a/exercises/108_labeled_switch.zig --- exercises/108_labeled_switch.zig 2024-09-20 12:09:24.370066539 +0200
+++ b/exercises/108_labeled_switch.zig +++ answers/108_labeled_switch.zig 2024-09-20 12:09:06.499711739 +0200
@@ -65,13 +65,13 @@ pub fn main() void { @@ -65,13 +65,13 @@
// how would you fix it? // how would you fix it?
pr: switch (@as(PullRequestState, PullRequestState.Draft)) { pr: switch (PullRequestState.Draft) {
PullRequestState.Draft => continue :pr PullRequestState.InReview, PullRequestState.Draft => continue :pr PullRequestState.InReview,
- PullRequestState.InReview => continue :pr PullRequestState.Rejected, - PullRequestState.InReview => continue :pr PullRequestState.Rejected,
+ PullRequestState.InReview => continue :pr PullRequestState.Approved, + PullRequestState.InReview => continue :pr PullRequestState.Approved,
PullRequestState.Approved => continue :pr PullRequestState.Merged, PullRequestState.Approved => continue :pr PullRequestState.Merged,
PullRequestState.Rejected => { PullRequestState.Rejected => {
std.debug.print("The pull request has been rejected", .{}); std.debug.print("The pull request has been rejected.\n", .{});
return; return;
}, },
- PullRequestState.Merged => break, // Would you know where to break to? - PullRequestState.Merged => break, // Would you know where to break to?
+ PullRequestState.Merged => break :pr, // 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", .{});
} }