We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
@defer
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
null
For example, ArenaAllocator could be used like this:
ArenaAllocator
let foo = ArenaAllocator.init(@defer, alloc);
Manually calling deinit:
deinit
let foo = ArenaAllocator.init(null, alloc); foo.deinit()
The init function calls the provided defer function, defer_arg, like this (requires closure stntax):
init
defer_arg
if (defer_arg) |defer| { defer(fn() void { self.deinit() }); }
The text was updated successfully, but these errors were encountered:
Duplicate of #782.
Sorry, something went wrong.
No branches or pull requests
With this built-in function, it would be possible for functions to accept
@defer
ornull
as an argument to prevent forgetting to defer something.For example,
ArenaAllocator
could be used like this:Manually calling
deinit
:The
init
function calls the provided defer function,defer_arg
, like this (requires closure stntax):The text was updated successfully, but these errors were encountered: