zig-sqlite icon indicating copy to clipboard operation
zig-sqlite copied to clipboard

Simplify use of enums

Open Traxar opened this issue 1 year ago • 1 comments

It would be very nice for zig-sqlite to deal with converting enums to ints and back on its own. Having to write this at call site causes unnecessary boilerplate. As seen in this example:

try select.bind(.{
        .id = filter.id,
        .name = filter.name,
        .status = @enumToInt(filter.status),
    });

instead of just being able to:

try select.bind(filter);

Traxar avatar Jan 23 '24 10:01 Traxar

I'm not opposed to adding this but I would want to avoid using @enumFromInt so that parsing an invalid value doesn't invoke undefined behavior.

I'll keep this open as a note to myself for the next time I make some changes.

joeltg avatar Jan 29 '24 07:01 joeltg