Assert
Module
Implements various asserts.
assert_param
assert_param[cond: Bool]()
Asserts that the condition is true in the parameter domain.
The assert_param
is similar to static_assert
in C++ and is used to introduce constraints on the enclosing function. In Mojo, the assert places a constraint on the function.
Parameters:
- cond (
Bool
): The bool value to assert.
assert_param_msg
assert_param_msg[cond: Bool, msg: StringLiteral]()
Asserts that the condition is true in the parameter domain.
The assert_param
is similar to static_assert
in C++ and is used to introduce constraints on the enclosing function. In Mojo, the assert places a constraint on the function. The message is displayed when the assertion fails.
Parameters:
- cond (
Bool
): The bool value to assert. - msg (
StringLiteral
): The message to display on failure.
debug_assert
debug_assert(cond: Bool, msg: StringLiteral)
Asserts that the condition is true.
The debug_assert
is similar to assert
in C++. It is a no-op in release builds.
Args:
- cond (
Bool
): The bool value to assert. - msg (
StringLiteral
): The message to display on failure.