From 77c79140c7b0aa443adf74c05364ddbf614856df Mon Sep 17 00:00:00 2001 From: Dave Gauer Date: Sat, 19 Mar 2022 19:38:05 -0400 Subject: 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) { --- exercises/076_sentinels.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'exercises/076_sentinels.zig') 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 -- cgit v1.2.3-ZIG