rust-lang / rust-lang/rust

Tracking Issue for `alloc_slice_into_array`.

Open
#148,082 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

C-tracking-issue S-tracking-unimplemented T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Feature gate: #![feature(alloc_slice_into_array)]

Branched from: #133508

This is a tracking issue for adding conversion functions going from allocated slices to allocated arrays.

Public API
// 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>;
}

// alloc::vec

impl<T> Vec<T> {
    pub fn into_array<const N: usize>(self) -> Result<Box<[T; N]>, Self>;
}
Steps / History
  • API change proposal (ACP): #496
  • Implementation:
    • Implementation for Box<[_]>, Rc<[_]>, and Arc<[_]>: #134379
    • Update feature gates and tracking issues in source: #147540
    • Support custom allocators: #154925
    • Reimplementation for using Result instead of Option: #156810
    • Implementation for Vec<_>: #156234
  • Final comment period (FCP)
  • Stabilisation
Unresolved Questions
  • const-compatibility?
  • Option or Result? : Result (assumed.)
  • Implementations for Mutex and RwLock?
  • Vec::into_boxed_array?
  • String::into_boxed_bytes_array?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the API change proposal #496 and the implementation PRs #134379, #154925, #156810, and #156234. Check the unresolved questions and the current feature-gate state; completion requires resolving the remaining design questions, holding the final comment period, and stabilizing the APIs.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.