From 8a2e40040b32378cf8a71af1cd5f19d163417f55 Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Fri, 27 Feb 2026 03:38:26 +0100 Subject: replace deprecated `mem.indexOf` with `mem.find` --- exercises/065_builtins2.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'exercises/065_builtins2.zig') diff --git a/exercises/065_builtins2.zig b/exercises/065_builtins2.zig index 2d13994..3d34757 100644 --- a/exercises/065_builtins2.zig +++ b/exercises/065_builtins2.zig @@ -147,9 +147,9 @@ pub fn main() void { // We'll be seeing @typeName again in Exercise 070. For now, you can // see that it takes a Type and returns a u8 "string". fn maximumNarcissism(myType: type) []const u8 { - const indexOf = @import("std").mem.indexOf; + const find = @import("std").mem.find; // Turn "065_builtins2.Narcissus" into "Narcissus" const name = @typeName(myType); - return name[indexOf(u8, name, ".").? + 1 ..]; + return name[find(u8, name, ".").? + 1 ..]; } -- cgit v1.2.3 From 686342375ed3f6ccd80b8483d37817d5a7bc8d8e Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Fri, 27 Feb 2026 03:55:37 +0100 Subject: improve comment stating 'Zig 0.10.0' @typeName change --- exercises/065_builtins2.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'exercises/065_builtins2.zig') diff --git a/exercises/065_builtins2.zig b/exercises/065_builtins2.zig index 2d13994..0fde989 100644 --- a/exercises/065_builtins2.zig +++ b/exercises/065_builtins2.zig @@ -137,12 +137,13 @@ pub fn main() void { } // NOTE: This exercise did not originally include the function below. -// But a change after Zig 0.10.0 added the source file name to the -// type. "Narcissus" became "065_builtins2.Narcissus". +// After Zig 0.10.0, `@typeName` began prefixing the returned type name +// with the source file name. For example, "Narcissus" became +// "065_builtins2.Narcissus". // // To fix this, we've added this function to strip the filename from // the front of the type name. (It returns a slice of the type name -// starting at the index + 1 of character ".") +// starting just after the ".") // // We'll be seeing @typeName again in Exercise 070. For now, you can // see that it takes a Type and returns a u8 "string". -- cgit v1.2.3