Skip to content

Commit 501c78e

Browse files
committed
fix: Transition from ArrayList to ArrayListUnmanaged
This fix anticipates upcoming changes in Zig 0.15 which will make `ArrayList` a synonym for `ArrayListUnmanaged` while still maintaining compatibility (for now) with Zig 0.14
1 parent 6889b2d commit 501c78e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/tests.zig

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const std = @import("std");
22
const testing = std.testing;
3+
const ArrayList = std.ArrayListUnmanaged; // delete this once 0.14 support is no longer necessary
34

45
const zlua = @import("zlua");
56

@@ -874,14 +875,14 @@ test "dump and load" {
874875
const writer = struct {
875876
fn inner(l: *Lua, buf: []const u8, data: *anyopaque) bool {
876877
_ = l;
877-
var arr: *std.ArrayList(u8) = @ptrCast(@alignCast(data));
878-
arr.appendSlice(buf) catch return false;
878+
var arr: ArrayList(u8) = @ptrCast(@alignCast(data));
879+
arr.appendSlice(std.testing.allocator, buf) catch return false;
879880
return true;
880881
}
881882
}.inner;
882883

883-
var buffer: std.ArrayList(u8) = .init(testing.allocator);
884-
defer buffer.deinit();
884+
var buffer: ArrayList(u8) = .empty;
885+
defer buffer.deinit(std.testing.allocator);
885886

886887
// save the function as a binary chunk in the buffer
887888
if (zlua.lang == .lua53 or zlua.lang == .lua54) {
@@ -898,7 +899,7 @@ test "dump and load" {
898899
const reader = struct {
899900
fn inner(l: *Lua, data: *anyopaque) ?[]const u8 {
900901
_ = l;
901-
const arr: *std.ArrayList(u8) = @ptrCast(@alignCast(data));
902+
const arr: *ArrayList(u8) = @ptrCast(@alignCast(data));
902903
return arr.items;
903904
}
904905
}.inner;

0 commit comments

Comments
 (0)