Closed
Description
Example:
trait Foo {
const N: usize;
const ARRAY: [i32;Self::N];
}
The compiler will report an error:
error: unconstrained generic constant
--> src/main.rs:38:5
|
38 | const ARRAY: [i32;Self::N];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: try adding a `where` bound using this expression: `where [(); Self::N]:`
Honestly speaking, I don't get what the suggestion means. Is it allowed to use generic_const_exprs like this? Or the only way to do this is by writing
trait Foo<const N: usize> {
const ARRAY: [i32;N];
}
?