Skip to content

Commit a971ae6

Browse files
committed
support latest zig (non-mutable variables MUST be const)
1 parent e8e5ad7 commit a971ae6

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/kv.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub const Kv = struct {
7373

7474
pub fn ctx(self: *Kv, value: []const u8) void {
7575
if (!self.writeKeyForValue("@ctx", value.len)) return;
76-
var pos = self.pos;
76+
const pos = self.pos;
7777
@memcpy(self.buf[pos..pos+value.len], value);
7878
self.pos = pos + value.len;
7979
}
@@ -163,7 +163,7 @@ pub const Kv = struct {
163163
pub fn stringSafe(self: *Kv, key: []const u8, value: ?[]const u8) void {
164164
if (value) |v| {
165165
if (!self.writeKeyForValue(key, v.len)) return;
166-
var pos = self.pos;
166+
const pos = self.pos;
167167
@memcpy(self.buf[pos..pos+v.len], v);
168168
self.pos = pos + v.len;
169169
} else {

src/pool.zig

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub const Pool = struct {
2323
const loggers = try allocator.alloc(*Kv, size);
2424

2525
for (0..size) |i| {
26-
var kv = try allocator.create(Kv);
26+
const kv = try allocator.create(Kv);
2727
kv.* = try Kv.init(allocator, config);
2828
loggers[i] = kv;
2929
}
@@ -57,7 +57,7 @@ pub const Pool = struct {
5757
self.mutex.unlock();
5858
const allocator = self.allocator;
5959

60-
var kv = allocator.create(Kv) catch |e| {
60+
const kv = allocator.create(Kv) catch |e| {
6161
logDynamicAllocationFailure(e);
6262
return null;
6363
};
@@ -226,16 +226,16 @@ test "pool: acquire and release" {
226226
var p = try Pool.init(t.allocator, min_config);
227227
defer p.deinit();
228228

229-
var l1a = p.acquire() orelse unreachable;
230-
var l2a = p.acquire() orelse unreachable;
231-
var l3a = p.acquire() orelse unreachable; // this should be dynamically generated
229+
const l1a = p.acquire() orelse unreachable;
230+
const l2a = p.acquire() orelse unreachable;
231+
const l3a = p.acquire() orelse unreachable; // this should be dynamically generated
232232

233233
try t.expectEqual(false, l1a == l2a);
234234
try t.expectEqual(false, l2a == l3a);
235235

236236
p.release(l1a);
237237

238-
var l1b = p.acquire() orelse unreachable;
238+
const l1b = p.acquire() orelse unreachable;
239239
try t.expectEqual(true, l1a == l1b);
240240

241241
p.release(l3a);
@@ -455,7 +455,7 @@ test "pool: logger" {
455455
}
456456

457457
test "pool: loggerL" {
458-
var min_config = Config{.pool_size = 1, .max_size = 100};
458+
const min_config = Config{.pool_size = 1, .max_size = 100};
459459
var out = std.ArrayList(u8).init(t.allocator);
460460
defer out.deinit();
461461

0 commit comments

Comments
 (0)