Function assert [src]
Invokes detectable illegal behavior when ok is false.
In Debug and ReleaseSafe modes, calls to this function are always
generated, and the unreachable statement triggers a panic.
In ReleaseFast and ReleaseSmall modes, calls to this function are optimized
away, and in fact the optimizer is able to use the assertion in its
heuristics.
Inside a test block, it is best to use the std.testing module rather than
this function, because this function may not detect a test failure in
ReleaseFast and ReleaseSmall mode. Outside of a test block, this assert
function is the correct function to use.
Prototype
pub fn assert(ok: bool) void
Parameters
ok: bool
Source
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}