rtl: add custom assert

This commit is contained in:
Loïc Grégoire
2026-09-13 21:43:42 -04:00
parent 084d28b829
commit 5c160382cc
+13
View File
@@ -84,6 +84,19 @@ pub fn assert_interface(T: type, I: type) void {
} }
} }
pub fn assert(condition: bool, comptime msg: []const u8, args: anytype) void {
if (!condition) {
@branchHint(.unlikely);
switch (@import("builtin").mode) {
.ReleaseFast, .ReleaseSmall => unreachable,
.Debug, .ReleaseSafe => {
std.debug.panicExtra(@returnAddress(), "Assertion failed: " ++ msg, args);
},
}
}
}
test { test {
std.testing.refAllDecls(@This()); std.testing.refAllDecls(@This());
} }