If you don't mind me extending the topic a bit: I bumped into a similar issue, which I described here:
One of the solutions for the original question would be to use something like:
type MultiDimensionSlices[T any] interface{
T | []T | [][]T | [][][]T ...
}
But it also fails with `term cannot be a type parameter`.
Is this a temporary limitation (to be fixed in some future Go compiler), or fundamentally it doesn't work for some reason ?
Also if I remove the "scalar" version (so remove T from the constraint types list), and define:
type MultiDimensionSlices[T any] interface{
[]T | [][]T | [][][]T ...
}
type Number interface { int | float32 }
func rank[S MultiDimensionSlices[T], T Number](value MultiDimensionSlices) int {...}
I cannot simply call:
rank([][]float32{{1}}) // == 2
because it's not able to infer the type. Instead I'm forced to do:
rank[[][]float32, float32]([][]float32{{1}})
Any way to have the automatic type inference work in this case ?
Thanks!!