Merge pull request 'fixed that @hasDecl only works on public functions now' (#515) from comptime_fix into main

Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/515
This commit is contained in:
Chris Boesch
2026-08-31 13:38:31 +02:00
2 changed files with 6 additions and 6 deletions
+4 -4
View File
@@ -25,12 +25,12 @@ const Duck = struct {
location_x: i32 = 0, location_x: i32 = 0,
location_y: i32 = 0, location_y: i32 = 0,
fn waddle(self: *Duck, x: i16, y: i16) void { pub fn waddle(self: *Duck, x: i16, y: i16) void {
self.location_x += x; self.location_x += x;
self.location_y += y; self.location_y += y;
} }
fn quack(self: Duck) void { pub fn quack(self: Duck) void {
if (self.loudness < 4) { if (self.loudness < 4) {
print("\"Quack.\" ", .{}); print("\"Quack.\" ", .{});
} else { } else {
@@ -44,12 +44,12 @@ const RubberDuck = struct {
location_x: i32 = 0, location_x: i32 = 0,
location_y: i32 = 0, location_y: i32 = 0,
fn waddle(self: *RubberDuck, x: i16, y: i16) void { pub fn waddle(self: *RubberDuck, x: i16, y: i16) void {
self.location_x += x; self.location_x += x;
self.location_y += y; self.location_y += y;
} }
fn quack(self: RubberDuck) void { pub fn quack(self: RubberDuck) void {
// Assigning an expression to '_' allows us to safely // Assigning an expression to '_' allows us to safely
// "use" the value while also ignoring it. // "use" the value while also ignoring it.
_ = self; _ = self;
+2 -2
View File
@@ -1,5 +1,5 @@
--- exercises/070_comptime5.zig 2023-10-03 22:15:22.125574535 +0200 --- exercises/070_comptime5.zig 2026-08-31 13:28:01.202098783 +0200
+++ answers/070_comptime5.zig 2023-10-05 20:04:07.159435482 +0200 +++ answers/070_comptime5.zig 2026-08-31 13:27:33.431493595 +0200
@@ -123,8 +123,8 @@ @@ -123,8 +123,8 @@
// Please make sure MyType has both waddle() and quack() // Please make sure MyType has both waddle() and quack()
// methods: // methods: