Hey, basically, I want to make this code syntactically valid:
impl<
Ul,
const ROW: usize,
const COL: usize,
#[cfg(feature = "chords")] const N: usize,
#[cfg(feature = "chords")] const K: usize,
> Layout<Ul, ROW, COL, #[cfg(feature = "chords")] N, #[cfg(feature = "chords")] K>
{
// etc.
}
The compiler tells me:
error: invalid const generic expression
--> src/layout.rs:169:55
|
169 | > Layout<Ul, ROW, COL, #[cfg(feature = "chords")] N, #[cfg(feature = "chords")] K>
| ^
|
help: expressions must be enclosed in braces to be used as const generic arguments
|
169 | > Layout<Ul, ROW, COL, #[cfg(feature = "chords")] { N }, #[cfg(feature = "chords")] K>
| + +
But if I try to add these braces, I get the exact same message again:
error: invalid const generic expression
--> src/layout.rs:169:54
|
169 | > Layout<Ul, ROW, COL, #[cfg(feature = "chords")]{ N }, #[cfg(feature = "chords")] K>
| ^^^^^
|
help: expressions must be enclosed in braces to be used as const generic arguments
|
169 | > Layout<Ul, ROW, COL, #[cfg(feature = "chords")]{ { N } }, #[cfg(feature = "chords")] K>
| + +
How am I supposed to write that?
Edit: well, it appears that it does not work either with regular generic parameters: Rust Playground