Generics over the size of an array type


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].


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


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


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