constrained
Module
Implements compile time contraints.
These are Mojo built-ins, so you don’t need to import them.
constrained
constrained[cond: Bool, msg: StringLiteral]()
Compile time checks that the condition is true.
The constrained
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.
constrained[cond: Bool]()
Compile time checks that the condition is true.
The constrained
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.