Generics over the size of an array type


#1

Currently, we can only implement a trait for [T; N] where N is a non-negative compile time constant size. What are the difficulties in supporting generics over the size of an array type? Any ideas or plans for this? Perhaps, we need an extension like impl<T> Trait for [T; N: usize].


#2

It’s a well-known rough spot. This looks like the main discussion thread:


#3

There is generic-array which implements this in a third-party crate.


#4

There is the unstable trait FixedSizeArray, but it’s not likely to be the final solution.