From 3a0423c600db39b8d939b02d30f38eb82a00b08b Mon Sep 17 00:00:00 2001 From: Vincent Rischmann Date: Sun, 25 Oct 2020 00:33:40 +0200 Subject: check the type of the options argument --- sqlite.zig | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sqlite.zig') diff --git a/sqlite.zig b/sqlite.zig index 8aaef3a..46f2e7e 100644 --- a/sqlite.zig +++ b/sqlite.zig @@ -254,6 +254,9 @@ pub const Statement = struct { /// an allocator used to read text and blobs. /// pub fn one(self: *Self, comptime Type: type, options: anytype) !?Type { + if (!comptime std.meta.trait.is(.Struct)(@TypeOf(options))) { + @compileError("options passed to all must be a struct"); + } const TypeInfo = @typeInfo(Type); var result = c.sqlite3_step(self.stmt); @@ -295,6 +298,9 @@ pub const Statement = struct { /// Note that for this function the allocator is mandatory. /// pub fn all(self: *Self, comptime Type: type, options: anytype) ![]Type { + if (!comptime std.meta.trait.is(.Struct)(@TypeOf(options))) { + @compileError("options passed to all must be a struct"); + } const TypeInfo = @typeInfo(Type); var rows = std.ArrayList(Type).init(options.allocator); -- cgit v1.2.3