Closed Arwalk closed 11 months ago
Probably can use hasDecl or something like that to know if a deinit "method" exists.
This example works, so all our problems are solved.
const Demo2 = struct {
a : ?u32,
b : ?u32,
pub const _desc_table = .{
.a = fd(1, .{.Varint = .ZigZagOptimized}),
.b = fd(2, .{.Varint = .ZigZagOptimized}),
};
pub fn encode(self: Demo2, allocator: *mem.Allocator) ![]u8 {
return pb_encode(self, allocator);
}
pub fn deinit(self: Demo2) void {
pb_deinit(self);
}
};
test "hasdecl" {
try testing.expect(@hasDecl(Demo2, "deinit"));
}
Complex map keys/value deinit are not an easy feat to manage. If a key/value type requires a deinit call to be properly freed, it is currently not managed in any way.