fix: slice of structs

This commit is contained in:
Lucas F. 2026-01-22 09:32:30 -03:00
parent 59e543ca89
commit a6d8795c79

View file

@ -42,6 +42,20 @@ pub const Context = struct {
return Value{ .string = try time.formatDateTime(self.allocator(), value, "Y-m-d H:i:s") };
}
if (@typeInfo(T) == .pointer) {
if (@typeInfo(T).pointer.size == .slice) {
std.debug.print("slice: {any}\n", .{@typeInfo(T).pointer.child});
if (@typeInfo(@typeInfo(T).pointer.child) == .@"struct") {
std.debug.print("struct: {s}\n", .{@typeName(@typeInfo(T).pointer.child)});
var list = try self.allocator().alloc(Value, value.len);
for (value, 0..) |item, i| {
list[i] = try self.toValue(item);
}
return Value{ .list = list };
}
}
}
return switch (@typeInfo(T)) {
.bool => Value{ .bool = value },
.int, .comptime_int => Value{ .int = @intCast(value) },