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

1 Like

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

https://github.com/rust-lang/rfcs/issues/1038

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.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.