-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.F-const_generics`#![feature(const_generics)]``#![feature(const_generics)]`T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
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.
95th, lukechu10, technic and mo-rijndaelDutchGhost and pickfire
Metadata
Metadata
Assignees
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.F-const_generics`#![feature(const_generics)]``#![feature(const_generics)]`T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.