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

Idea to handle text and blob internally

Open robinsoncol opened this issue 1 year ago • 0 comments

I haven't thought this through, but what if we could do something like this to distinguish between text and blob internally:

pub const Type = union(TypeTag) {
    blob: std.builtin.Type.Pointer,
    text: std.builtin.Type.Pointer,
    ...
    
    pub fn parse(comptime T: type) Type {
        return switch (T) {
            else => switch (@typeInfo(T)) {
                ...
                .Pointer => |info| {
                 if (info.is_const) {
                   return .{ .text = info };
                  } else {
                    return .{ .blob = info };
                   }
                },
                ...
            },
        };
    }
};

We can then remove Text, text, Blob and blob...

robinsoncol avatar May 25 '24 18:05 robinsoncol