My program just segfaults when I try to append a struct type to my array list
const std = @import("std");
const Foo = struct {
name: [*:0]const u8,
id: u32,
};
pub fn main() void {
var gpa = std.heap.GeneralPurposeAllocator(.{}).init;
defer {
if (gpa.deinit() == .leak) {
std.debug.panic("Leaked memory.", .{});
}
}
const foo = Foo {.id = 0, .name = "hello"};
var arr = std.ArrayList(Foo).init(gpa.allocator());
defer arr.deinit();
arr.append(foo) catch unreachable;
}