3 ms·
Most zig code still handles OOM via panic. You'd have to go out of your way to somehow make it less safe than that. Dealing with an error by passing it up the c
by AnIdiotOnTheNet 8y ago
Most zig code still handles OOM via panic. You'd have to go out of your way to somehow make it less safe than that. Dealing with an error by passing it up the call stack (eventually to the panic handler) is actually easier than ignoring it:
//kick any error up the call stack
var buffer = try allocator.alloc(u8, 500);
//in debug builds, assert that this will not fail
//in release-fast failure will result in undefined
//behavior.
var buffer = allocator.alloc(u8, 500) catch unreachable;