Skip to content

Commit

Permalink
add missing src/strings.zig
Browse files Browse the repository at this point in the history
  • Loading branch information
nektro committed Aug 8, 2021
1 parent d09fd28 commit 2a400d9
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/strings.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const std = @import("std");

const string = []const u8;

pub fn splitAlloc(alloc: *std.mem.Allocator, input: string, delim: string) ![]const string {
const result = &std.ArrayList(string).init(alloc);
defer result.deinit();
var it = std.mem.split(input, delim);
while (it.next()) |item| {
try result.append(item);
}
return result.toOwnedSlice();
}

pub const list = struct {
//

pub fn contains(haystack: []const string, needle: string) bool {
for (haystack) |item| {
if (std.mem.eql(u8, item, needle)) {
return true;
}
}
return false;
}
};

0 comments on commit 2a400d9

Please sign in to comment.