ive got this code for my matrix struct:
pub fn Matrix(comptime T: type) type {
return struct {
const Self = @This();
rows: usize,
cols: usize,
data: []T,
allocator: std.mem.Allocator,
pub fn init(allocator: std.mem.Allocator, m: usize, n: usize) !Self {
return Self{
.rows = m,
.cols = n,
.data = try allocator.alloc(T, n * m),
.allocator = allocator,
};
}
// other stuff
};
}
and im trying to use std.zon.stringify to save the matrix into a file (to load it later). but when i try to serialize it:
try stringify.serialize(Mat, options, writer);
I get this compile time error:
/.../zig-0.15.0/lib/std/debug.zig:554:14: error: reached unreachable code
if (!ok) unreachable; // assertion failure
^~~~~~~~~~~
/.../zig-0.15.0/lib/std/zon/stringify.zig:493:28: note: called at comptime here
comptime assert(canSerializeType(@TypeOf(val)));
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
idk how my struct is unserializeable, maybe one of the members cause the problem? My guess is the data slice (although it worked fine when i dont use heap allocated memory). Thanks in advance!