fn test2<const N: u32>()
where [(); (N % 4 == 0) as usize -1]: {
}
to constrain N at compile time.
Now the colon at the end of the where clause has a special meaning? It doesn't work without it.
It should be a place for traits but we don't specify any, right ?
Yes, that where clause is placing no trait requirements on the type. You could put a comma after the colon to specify another where clause.
But it does require that the type exists and is well-formed. An array type with length of Error (due to const evaluation panic) fails the requirement, so the method can't be called.
Yes, it's part of the const well-formedness bound syntax of the nightly generic_const_exprs feature. The final syntax for const well-formedness bounds is still up for debate:
We currently use where [(); expr]: as a way to add additional const wf bounds.
Once we have started experimenting with this it is probably worth it to add
a more intuitive way to add const wf bounds.
A possible syntax is where (expr), . This is not intended to be part of the
initial unstable implementation however.