| ... | ... | @@ -30,3 +30,14 @@ pub fn addSentinel(alloc: *std.mem.Allocator, comptime T: type, input: []const T |
| 30 | 30 | const str = list.toOwnedSlice(); |
| 31 | 31 | return str[0 .. str.len - 1 :sentinel]; |
| 32 | 32 | } |
| 33 | |
| 34 | const alphabet = "0123456789abcdefghijklmnopqrstuvwxyz"; |
| 35 | |
| 36 | pub fn randomSlice(alloc: *std.mem.Allocator, rand: *std.rand.Random, comptime T: type, len: usize) ![]const T { |
| 37 | var buf = try alloc.alloc(T, len); |
| 38 | var i: usize = 0; |
| 39 | while (i < len) : (i += 1) { |
| 40 | buf[i] = alphabet[rand.int(usize) % alphabet.len]; |
| 41 | } |
| 42 | return buf; |
| 43 | } |