Constraints and Static Checks
Validate parameters before runtime.
Catching Mistakes Before Runtime
A constraint is a rule the compiler verifies about your parameters, stopping a bad build before the program ever runs. ⚙️
The constrained Function
Call constrained with a compile-time condition; if it is false, compilation fails with the message you supply.
fn half[n: Int]():
constrained[n % 2 == 0, "n must be even"]()All lessons in this course
- Parametric Algorithms
- Compile-Time Loop Unrolling
- Conditional Compilation
- Constraints and Static Checks