aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/exercises
diff options
context:
space:
mode:
authorDave Gauer <dave@ratfactor.com>2022-03-19 19:38:05 -0400
committerDave Gauer <dave@ratfactor.com>2022-03-19 19:38:05 -0400
commitf34b6aa02408cbc1483ab182592a2f8d5b0a4f9a (patch)
treebc301504463e858cdd82002d4722bf4df1f80b71 /exercises
parent3f922a35293c3e5e8cad08f400e4003075cec071 (diff)
Update sentinel type for v0.10.0
Fixes .../076_sentinels.zig:95:30: error: incompatible types: 'u32' and '?*const anyopaque': while (my_seq[i] != my_sentinel) {
Diffstat (limited to 'exercises')
-rw-r--r--exercises/076_sentinels.zig7
1 files changed, 4 insertions, 3 deletions
diff --git a/exercises/076_sentinels.zig b/exercises/076_sentinels.zig
index 5d5f70e..6f7abae 100644
--- a/exercises/076_sentinels.zig
+++ b/exercises/076_sentinels.zig
@@ -39,6 +39,7 @@
// data being terminated!
//
const print = @import("std").debug.print;
+const sentinel = @import("std").meta.sentinel;
pub fn main() void {
// Here's a zero-terminated array of u32 values:
@@ -71,12 +72,12 @@ pub fn main() void {
// complete, but there are a couple missing bits. Please fix
// them!
fn printSequence(my_seq: anytype) void {
- const my_type = @typeInfo(@TypeOf(my_seq));
+ const my_typeinfo = @typeInfo(@TypeOf(my_seq));
// The TypeInfo contained in my_type is a union. We use a
// switch to handle printing the Array or Pointer fields,
// depending on which type of my_seq was passed in:
- switch (my_type) {
+ switch (my_typeinfo) {
.Array => {
print("Array:", .{});
@@ -87,7 +88,7 @@ fn printSequence(my_seq: anytype) void {
},
.Pointer => {
// Check this out - it's pretty cool:
- const my_sentinel = my_type.Pointer.sentinel;
+ const my_sentinel = sentinel(@TypeOf(my_seq));
print("Many-item pointer:", .{});
// Loop through the items in my_seq until we hit the