From c5cad45bcb9d90a0ea2f9b91f2d61a3fcbabe8a7 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Wed, 5 Jul 2023 00:57:53 -0700 Subject: [PATCH] collect: return a mutable slice since it doesnt need to be const --- src/sqlite3.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sqlite3.zig b/src/sqlite3.zig index 0e42297a61158eb517f77c696db90a16295933f7..90dadaedba79a4165d052e869f224bad80784fe0 100644 --- a/src/sqlite3.zig +++ b/src/sqlite3.zig @@ -32,11 +32,12 @@ fn prepare(self: *Self, comptime query: string) !sqlite.StatementType(.{}, query }; } -pub fn collect(self: *Self, alloc: std.mem.Allocator, comptime T: type, comptime query: string, args: anytype) ![]const T { +pub fn collect(self: *Self, alloc: std.mem.Allocator, comptime T: type, comptime query: string, args: anytype) ![]T { var stmt = try self.prepare(query); defer stmt.deinit(); var iter = try stmt.iteratorAlloc(T, alloc, args); var list = std.ArrayList(T).init(alloc); + errdefer list.deinit(); while (try iter.nextAlloc(alloc, .{})) |row| { try list.append(row); } -- 2.54.0