diff options
author | Dave Gauer <dave@ratfactor.com> | 2022-03-19 19:38:05 -0400 |
---|---|---|
committer | Dave Gauer <dave@ratfactor.com> | 2022-03-19 19:38:05 -0400 |
commit | 77c79140c7b0aa443adf74c05364ddbf614856df (patch) | |
tree | bc301504463e858cdd82002d4722bf4df1f80b71 /exercises/076_sentinels.zig | |
parent | c22544ece7dcf5cbfe0110c4919c83dd4cb0f85c (diff) | |
download | ziglings-77c79140c7b0aa443adf74c05364ddbf614856df.tar.gz ziglings-77c79140c7b0aa443adf74c05364ddbf614856df.tar.bz2 ziglings-77c79140c7b0aa443adf74c05364ddbf614856df.tar.xz ziglings-77c79140c7b0aa443adf74c05364ddbf614856df.zip |
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/076_sentinels.zig')
-rw-r--r-- | exercises/076_sentinels.zig | 7 |
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 |