A String struct made for Zig.
Inspired by this repo: https://github.com/clownpriest/strings/
To test:
$ cd zig-string/
$ zig test string.zig
Basic Usage:
conststd=@import("std");
constString=@import("/some/path/string.zig").String;
pubfnmain() !void {
varbuf: [1024]u8=undefined;
varfba=std.heap.ThreadSafeFixedBufferAllocator.init(buf[0..]);
vars=tryString.init(&fba.allocator, "hello, world");
defers.deinit();
varmatches=trys.findSubstringIndices(&fba.allocator, "hello");
deferfba.allocator.free(matches);
// Should print:// 0// hello, worldfor (matches) |val| {
std.debug.warn("{}\n", val);
}
std.debug.warn("{}\n", s.toSliceConst());
}