fix: slice of structs
This commit is contained in:
parent
59e543ca89
commit
a6d8795c79
1 changed files with 14 additions and 0 deletions
|
|
@ -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) },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue