Why can't const functions in Rust make calls to associated functions?

Viewed 5505

This:

const fn pow2(exp: u32) -> u32 {
    u32::pow(exp, 2)
}

Results in a compiler error:

error[E0015]: calls in constant functions are limited to constant functions, struct and enum constructors

Is there a way to do this?

I'd like to do:

pub const MY_BITMASK: u32 = pow2(4);
1 Answers
Related