I am trying to get a better understanding of const generic expressions and I have not been able run the following
trait Foo<const N: usize> {}
impl<const N: usize> Foo<{ N * N }> for () {}
because
the const parameter
N
is not constrained by the impl trait, self type, or predicates
I have also tried calculating the square root compile time, but
trait Bar<const N: usize> {
fn bar();
}
impl<const N: usize> Bar<N> for () {
fn bar() {
const L: i32 = 1 << N.ilog2();
}
}
but am running into an issue on N
can't use generic parameters from outer function
I'm not understanding why the first example is failing to compile as Foo is bound by N*N which should resolve to a number.