-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-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.needs-fcpThis change is insta-stable, or significant enough to need a team FCP to proceed.This change is insta-stable, or significant enough to need a team FCP to proceed.
Description
Feature gate: #![feature(slice_as_array)]
This is a tracking issue for adding conversion functions from slices to arrays.
Public API
impl<T> [T] {
pub const fn as_array<const N: usize>(&self) -> Option<&[T; N]>;
pub const fn as_mut_array<const N: usize>(&mut self) -> Option<&mut [T; N]>;
}
impl<T> *const [T] {
pub const fn as_array<const N: usize>(self) -> Option<*const [T; N]>;
}
impl<T> *mut [T] {
pub const fn as_mut_array<const N: usize>(self) -> Option<*mut [T; N]>;
}
// alloc::boxed
impl<T> Box<[T]> {
pub fn into_array<const N: usize>(self) -> Result<Box<[T; N]>, Self>;
}
// alloc::rc
impl<T> Rc<[T]> {
pub fn into_array<const N: usize>(self) -> Result<Rc<[T; N]>, Self>;
}
// alloc::sync
impl<T> Arc<[T]> {
pub fn into_array<const N: usize>(self) -> Result<Arc<[T; N]>, Self>;
}Steps / History
- API change proposal (ACP): #496
- Implementation:
- ... for
[_],*const [_], and*mut [_]: Addas_arrayandas_mut_arrayconversion methods to slices. #133512 - Fix docs for
<[_]>::as_array: Fix docs for<[T]>::as_array. #133743 - Implementation for
Box<[_]>,Rc<[_]>, andArc<[_]>: Addinto_arrayconversion destructors forBox,Rc, andArc. #134379 - Reimplementation for using
ResultinBox<[_]>,Rc<[_]>, andArc<[_]>
- ... for
- Final comment period (FCP):
- ... for
[_],*const [_], and*mut [_] - ... for
Box<[_]>,Rc<[_]>, andArc<[_]>
- ... for
- Stabilisation:
- Stabilisation of
[_],*const [_], and*mut [_]: Stabiliseas_arrayin[_]and*const [_]; stabiliseas_mut_arrayin[_]and*mut [_]. #147540 - Stabilisation of
Box<[_]>,Rc<[_]>, andArc<[_]>
- Stabilisation of
Unresolved Questions
const-compatibility for the non-primitive types?:OptionorResultfor the owning conversions?Result- Implementations for
MutexandRwLock? Vec::into_boxed_array?str::as_bytes_arrayandString::into_boxed_bytes_array?
joseluis, YYMMYB, cxw620, MathiasPius, TheNullicorn and 2 more
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-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.needs-fcpThis change is insta-stable, or significant enough to need a team FCP to proceed.This change is insta-stable, or significant enough to need a team FCP to proceed.