Closed
Description
With this built-in function, it would be possible for functions to accept @defer
or null
as an argument to prevent forgetting to defer something.
For example, ArenaAllocator
could be used like this:
let foo = ArenaAllocator.init(@defer, alloc);
Manually calling deinit
:
let foo = ArenaAllocator.init(null, alloc);
foo.deinit()
The init
function calls the provided defer function, defer_arg
, like this (requires closure stntax):
if (defer_arg) |defer| {
defer(fn() void {
self.deinit()
});
}
Metadata
Metadata
Assignees
Labels
No labels