| ... | @@ -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 | } |
| 490 | | 490 | |
| | 491 | pub 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 | |
| 491 | pub fn opslice(slice: anytype, index: usize) ?std.meta.Child(@TypeOf(slice)) { | 500 | pub 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]; |