Compile time
Constants
The compiler evaluates constant values before the program runs.
fn Answer() -> i32 { return 40 + 2; }
const Result: i32 = Answer();
fn main() -> i32 {
return Result;
}terminal
hopper run demo src
Constant evaluation runs on MIR, the same intermediate code as the interpreter. It cannot call a separately compiled dependency whose function body is unavailable.