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