1const std = @import("std");
2const string = []const u8;
3const extras = @import("./lib.zig");
4
5pub fn indexOfSlice(comptime T: type, haystack: []const []const T, needle: []const T) ?usize {
6 for (haystack, 0..) |item, i| {
7 if (std.mem.eql(u8, item, needle)) {
8 return i;
9 }
10 }
11 return null;
12}
13
14test {
15 try std.testing.expect(indexOfSlice(u8, &.{ "a", "b", "c", "d" }, "b") == 1);
16}
17test {
18 try std.testing.expect(indexOfSlice(u8, &.{}, "b") == null);
19}