Feature gate: #![feature(slice_first_last_chunk)]
This is a tracking issue for the slice::{split_,}{first,last}_chunk{,_mut}
API.
2024-09-06: Most of this is stable now, except for the const-ness of the mut
methods.
impl [T] { pub const fn first_chunk<const N: usize>(&self) -> Option<&[T; N]>; pub const fn first_chunk_mut<const N: usize>(&mut self) -> Option<&mut [T; N]>; pub const fn last_chunk<const N: usize>(&self) -> Option<&[T; N]>; pub const fn last_chunk_mut<const N: usize>(&mut self) -> Option<&mut [T; N]>; pub const fn split_first_chunk<const N: usize>(&self) -> Option<(&[T; N], &[T])>; pub const fn split_first_chunk_mut<const N: usize>(&mut self) -> Option<(&mut [T; N], &mut [T])>; pub const fn split_last_chunk<const N: usize>(&self) -> Option<(&[T; N], &[T])>; pub const fn split_last_chunk_mut<const N: usize>(&mut self) -> Option<(&mut [T; N], &mut [T])>; }
Note that this mirrors the existing, already-stabilised API:
impl [T] { pub const fn first(&self) -> Option<&T>; pub const fn first_mut(&mut self) -> Option<&mut T>; pub const fn last(&self) -> Option<&T>; pub const fn last_mut(&mut self) -> Option<&mut T>; pub const fn split_first(&self) -> Option<(&T, &[T])>; pub const fn split_first_mut(&mut self) -> Option<(&mut T, &mut [T])>; pub const fn split_last(&self) -> Option<(&T, &[T])>; pub const fn split_last_mut(&mut self) -> Option<(&mut T, &mut [T])>; }Steps / History
feature(const_slice_split_at_mut)
#101804 is stablesplit_last_chunk
? Consistency with split_last
would have it be -> Option<(&[T;N], &[T])>
as was ACPed, but it might be confusing to have the two slice-like things in the opposite order from every other API I can think of that returns two subslices of the original. In Add slice::{split_,}{first,last}_chunk{,_mut} #95198 (comment), @scottmcm expected -> Option<(&[T;N], &[T])>
for split_first_chunk
, but for it to be -> Option<(&[T], &[T;N])>
in split_last_chunk
so the tuple is "in order", in some sense.https://std-dev-guide.rust-lang.org/feature-lifecycle/api-change-proposals.html ↩
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩
maxwase, stepancheg and GrayJack
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4