authorgravatar for hello@nektro.netMeghan <hello@nektro.net> 2020-11-21 16:13:15 -08:00
committergravatar for hello@nektro.netMeghan <hello@nektro.net> 2020-11-21 16:13:15 -08:00
loge6ccf23520fb89e56a8a6c1a9c93b07d5177bba5
tree69b09ddf5017f5559ebec7a5e8a84289a17c8dbe
parentad5ff90838b11586a34d8a1480609a4127980080

add a generic version of util.list_contains


1 files changed, 9 insertions(+), 0 deletions(-)

src/util/funcs.zig+9
...@@ -121,3 +121,12 @@ pub fn open_dir_absolute(dpath: []const u8) !std.fs.Dir {...@@ -121,3 +121,12 @@ pub fn open_dir_absolute(dpath: []const u8) !std.fs.Dir {
121 .fd = (try std.fs.openFileAbsolute(dpath, .{})).handle,121 .fd = (try std.fs.openFileAbsolute(dpath, .{})).handle,
122 };122 };
123}123}
124
125pub fn list_contains_gen(comptime T: type, haystack: *std.ArrayList(T), needle: T) bool {
126 for (haystack.items) |item| {
127 if (item.eql(needle)) {
128 return true;
129 }
130 }
131 return false;
132}