Minor improvements.

This commit is contained in:
Chris Boesch 2024-09-20 12:10:55 +02:00
parent 94b5b4bf4b
commit d1b49f353e
No known key found for this signature in database
GPG key ID: 8712DF4D3E364668
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", .{});
} }