check package name length in shouldUnwrapRequire() (#3183)

* make sure length is equal

* add and use `indexEqualAny`
This commit is contained in:
Dylan Conway
2023-06-02 20:45:48 -07:00
committed by GitHub
parent d8e7436db0
commit 3e437a6ae0
2 changed files with 6 additions and 1 deletions

View File

@@ -127,6 +127,11 @@ pub inline fn indexAnyComptime(target: string, comptime chars: string) ?usize {
return null;
}
pub inline fn indexEqualAny(in: anytype, target: string) ?usize {
for (in, 0..) |str, i| if (eqlLong(str, target, true)) return i;
return null;
}
pub fn repeatingAlloc(allocator: std.mem.Allocator, count: usize, char: u8) ![]u8 {
var buf = try allocator.alloc(u8, count);
repeatingBuf(buf, char);