authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-07-05 00:57:53 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-07-05 00:57:53 -07:00
logc5cad45bcb9d90a0ea2f9b91f2d61a3fcbabe8a7
tree2f826b7efed3ee44dab21d35544333a03972677e
parentcd4471bb573fc17e479a67e9556ae8760c20de5c

collect: return a mutable slice since it doesnt need to be const


1 files changed, 2 insertions(+), 1 deletions(-)

src/sqlite3.zig+2-1
......@@ -32,11 +32,12 @@ fn prepare(self: *Self, comptime query: string) !sqlite.StatementType(.{}, query
3232 };
3333}
3434
35pub fn collect(self: *Self, alloc: std.mem.Allocator, comptime T: type, comptime query: string, args: anytype) ![]const T {
35pub fn collect(self: *Self, alloc: std.mem.Allocator, comptime T: type, comptime query: string, args: anytype) ![]T {
3636 var stmt = try self.prepare(query);
3737 defer stmt.deinit();
3838 var iter = try stmt.iteratorAlloc(T, alloc, args);
3939 var list = std.ArrayList(T).init(alloc);
40 errdefer list.deinit();
4041 while (try iter.nextAlloc(alloc, .{})) |row| {
4142 try list.append(row);
4243 }