Closed
Description
Creating a new issue about const-generic array splitting methods since it's been discussed on the array_chunks PR, where it really doesn't belong.
We probably want
impl [T] {
fn split_array<const N: usize>(&self) -> Option<(&[T; N], &[T])> { ... }
}
// requires more const generics work to be accepted by rustc AFAIK
impl<T, const N: usize> [T; N] {
fn split_array<const M: usize>(&self) -> (&[T; M], &[T; {N - M}]) { ... }
}
The possibility of a variadic array splitting function was also mentioned (at least that's my interpretation) but since there's not even an active RFC about variadic generics, I think that's a bit out of scope. The only thing one could do once the second split_array
above becomes possible is add split_array_2
, split_array_3
and so on.