authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-06-21 13:42:44 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-06-21 13:42:44 -07:00
log170fbd40697046e5c434510066d3166a397bb110
treebbbb5da2f890bb5bfa8773be3d9c30d6f9f68fc1
parente33d27927b95fe7e6c27db4b0960c28df31250ac

add matchesAny


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

src/lib.zig+9
...@@ -488,6 +488,15 @@ pub fn matchesAll(comptime T: type, haystack: []const u8, comptime needle: fn (T...@@ -488,6 +488,15 @@ pub fn matchesAll(comptime T: type, haystack: []const u8, comptime needle: fn (T
488 return true;488 return true;
489}489}
490490
491pub fn matchesAny(comptime T: type, haystack: []const u8, comptime needle: fn (T) bool) bool {
492 for (haystack) |c| {
493 if (needle(c)) {
494 return true;
495 }
496 }
497 return false;
498}
499
491pub fn opslice(slice: anytype, index: usize) ?std.meta.Child(@TypeOf(slice)) {500pub fn opslice(slice: anytype, index: usize) ?std.meta.Child(@TypeOf(slice)) {
492 if (slice.len <= index) return null;501 if (slice.len <= index) return null;
493 return slice[index];502 return slice[index];