A poolable string builder (aka string buffer) for Zig
0

Configure Feed

Select the types of activity you want to include in your feed.

accomodate Zig changes to std.builtin.Type

Karl Seguin (Aug 29, 2024, 7:54 PM +0800) c9a9e33b eeaf2eea

+6 -6
+1 -1
.gitignore
··· 1 1 zig-out/ 2 - zig-cache/ 2 + .zig-cache/
+3 -3
src/buffer.zig
··· 162 162 } 163 163 164 164 pub fn writeIntT(self: *Buffer, comptime T: type, value: T, endian: Endian) void { 165 - const l = @divExact(@typeInfo(T).Int.bits, 8); 165 + const l = @divExact(@typeInfo(T).int.bits, 8); 166 166 const pos = self.pos; 167 167 writeIntInto(T, self.buf, pos, value, l, endian); 168 168 self.pos = pos + l; ··· 334 334 } 335 335 336 336 pub fn writeIntT(self: *View, comptime T: type, value: T, endian: Endian) void { 337 - const l = @divExact(@typeInfo(T).Int.bits, 8); 337 + const l = @divExact(@typeInfo(T).int.bits, 8); 338 338 const pos = self.pos; 339 339 writeIntInto(T, self.buf.buf, pos, value, l, endian); 340 340 self.pos = pos + l; ··· 535 535 try t.expectString("hello 123 world", w.string()); 536 536 } 537 537 538 - fn testString(allocator: Allocator, random: std.rand.Random) []const u8 { 538 + fn testString(allocator: Allocator, random: std.Random) []const u8 { 539 539 var s = allocator.alloc(u8, random.uintAtMost(u8, 100) + 1) catch unreachable; 540 540 for (0..s.len) |i| { 541 541 s[i] = random.uintAtMost(u8, 90) + 32;
+2 -2
src/t.zig
··· 10 10 pub const expectString = std.testing.expectEqualStrings; 11 11 pub const exectSlice = std.testing.expectEqualSlices; 12 12 13 - pub fn getRandom() std.rand.DefaultPrng { 13 + pub fn getRandom() std.Random.DefaultPrng { 14 14 var seed: u64 = undefined; 15 15 std.posix.getrandom(std.mem.asBytes(&seed)) catch unreachable; 16 - return std.rand.DefaultPrng.init(seed); 16 + return std.Random.DefaultPrng.init(seed); 17 17 }