aboutsummaryrefslogtreecommitdiff
path: root/src/string_immutable.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/string_immutable.zig')
-rw-r--r--src/string_immutable.zig8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/string_immutable.zig b/src/string_immutable.zig
index 7613509c0..f8bf855f4 100644
--- a/src/string_immutable.zig
+++ b/src/string_immutable.zig
@@ -26,3 +26,11 @@ pub fn indexOf(self: string, str: u8) ?usize {
pub fn eql(self: string, other: anytype) bool {
return std.mem.eql(u8, self, other);
}
+
+pub fn index(self: string, str: string) i32 {
+ if (std.mem.indexOf(u8, self, str)) |i| {
+ return @intCast(i32, i);
+ } else {
+ return -1;
+ }
+}