Suppose I have a slice of a type that requires to be initiallized. The slice is created as:
var arr: []T = allocator.alloc(T, 10);
for some type T with the above restriction and some allocator. Is there any way to check if, for instance, arr[1] has been initialized?
For context, I want to know in a function, if a certain element has been initiallized, because if it has, I need to call the set funciton of that element, but if it has not, I need to create a new object of that type:
arr[1] = T{ .somedata = "foo" };
. And if T would be a packed struct from the start, a metadata field is your best option I would think.