Another option is removing the ArrayList
from ResponseArgs
and simply using a slice:
diff --git a/stringify-complex-structs-original.zig b/stringify-complex-structs.zig
index 17359f3..3e0b2df 100644
--- a/stringify-complex-structs-original.zig
+++ b/stringify-complex-structs.zig
@@ -6,7 +6,7 @@ const Item = struct {
};
const ResponseArgs = struct {
- docs: std.ArrayList(Item),
+ docs: []const Item,
};
const Response = struct {
@@ -31,7 +31,7 @@ pub fn main() !void {
const response = Response{
.status = 200,
.msg = "Found 0 docs",
- .args = ResponseArgs{ .docs = docs },
+ .args = ResponseArgs{ .docs = docs.items },
};
var buf: [100]u8 = undefined;