-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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.
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
[T]
,*const [T]
, and*mut [T]
: Addas_array
andas_mut_array
conversion methods to slices. #133512 - Fix docs for
<[T]>::as_array
: Fix docs for<[T]>::as_array
. #133743 - Implementation for
Box<[T]>
,Rc<[T]>
, andArc<[T]>
: Addinto_array
conversion destructors forBox
,Rc
, andArc
. #134379 - Reimplementation for using
Result
- Final comment period (FCP)
- Stabilization PR
Unresolved Questions
const
-compatible for the non-primitive types?Option
orResult
for the owning conversions?- Implementations for
Mutex
andRwLock
? Vec::into_boxed_array
?str::as_bytes_array
andString::into_boxed_bytes_array
?
joseluis, YYMMYB, cxw620, MathiasPius, TheNullicorn and 1 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.