Tracking Issue for slice_as_array
· Issue #133508 · rust-lang/rust (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
Feature gate: #![feature(slice_as_array)]
This is a tracking issue for adding conversion functions from slices to arrays.
Public API
impl [T] { pub const fn as_array(&self) -> Option<&[T; N]>;
pub const fn as_mut_array<const N: usize>(&mut self) -> Option<&mut [T; N]>;
}
impl *const [T] { pub const fn as_array(self) -> Option<*const [T; N]>; }
impl *mut [T] { pub const fn as_mut_array(self) -> Option<*mut [T; N]>; }
// alloc::boxed
impl Box<[T]> { pub fn into_array(self) -> Option<Box<[T; N]>>; }
// alloc::rc
impl Rc<[T]> { pub fn into_array(self) -> Option<Rc<[T; N]>>; }
// alloc::sync
impl Arc<[T]> { pub fn into_array(self) -> Option<Arc<[T; N]>>; }
Steps / History
- API change proposal (ACP): #496
- Implementation for
[T]
,*const [T]
, and*mut [T]
: Add as_array and as_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]>
: Add into_array conversion destructors for Box, Rc, and Arc. #134379 - 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
?