the.bay.news

Idiomatic way to deinit structures with allocated memory?

Ziggit
Idiomatic way to deinit structures with allocated memory?
So lets say I have a structure that only holds a pointer to an allocated memory and so the deinit is just freeing the memory and nothing else. What is the idiomatic way to do it? pub fn deinit(self: @This(), gpa: Allocator) void { gpa.free(self.slice); } This is sufficient, but it hides the semantics, because one could assume the “self” parameter being passed-in may not be modified since it is passed in by value. Same would go for *const @This() So it seems to show the semantics in the si...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.