diff options
author | 2021-08-25 17:56:06 -0700 | |
---|---|---|
committer | 2021-08-25 17:56:06 -0700 | |
commit | 454160646923e98f00e53df025e324d3d2c585d0 (patch) | |
tree | 731c5243ac48077ffa1f974dcf46f3bc176792b6 /src/string_immutable.zig | |
parent | 039bf6ecdb0be85ca78045b647de01bd176823c6 (diff) | |
download | bun-454160646923e98f00e53df025e324d3d2c585d0.tar.gz bun-454160646923e98f00e53df025e324d3d2c585d0.tar.zst bun-454160646923e98f00e53df025e324d3d2c585d0.zip |
latest
Former-commit-id: f5600d123d3710e7ea80ff2b7c66d13382462420
Diffstat (limited to 'src/string_immutable.zig')
-rw-r--r-- | src/string_immutable.zig | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/string_immutable.zig b/src/string_immutable.zig index 52b7e05ce..bac00ba45 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -13,6 +13,16 @@ pub inline fn contains(self: string, str: string) bool { return std.mem.indexOf(u8, self, str) != null; } +pub inline fn containsAny(in: anytype, target: string) bool { + for (in) |str| if (contains(str, target)) return true; + return false; +} + +pub inline fn indexAny(in: anytype, target: string) ?usize { + for (in) |str, i| if (indexOf(str, target) != null) return i; + return null; +} + pub inline fn indexOfChar(self: string, char: u8) ?usize { return std.mem.indexOfScalar(@TypeOf(char), self, char); } |