Is it possible to create allocation for struct that contains type as an attribute ?
For example
Example struct is
const Content = struct {
content: type,
name: []const u8,
};
Then, i would like to allocate memory for example of 2 * Content
I know i could use
const list: [2]CustomElement = .{ Content{ .content = Type, .name = "test" }, Content{ .content = Type, .name = "test" } };
But how to achieve them same thing using allocators ?
This doesn't work.
comptime {
var list = std.ArrayList(Content).init(test_allocator);
try list.append(Content{ .content = MyType , .name = "test" });
}
I get error
error: parameter of type '*std.array_list.ArrayListAligned(Content,null)' must be declared comptime
For short
Is it possible to build functionality for something like Box does in Rust ?