Stabilize slice_as_chunks library feature by scottmcm · Pull Request #139656 · rust-lang/rust (original) (raw)

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation12 Commits2 Checks6 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

@scottmcm

Draft as this needs #139163 to land first.

FCP: #74985 (comment)

Methods being stabilized are:

impl [T] { const fn as_chunks(&self) -> (&[[T; N]], &[T]); const fn as_rchunks(&self) -> (&[T], &[[T; N]]); const unsafe fn as_chunks_unchecked(&self) -> &[[T; N]]; const fn as_chunks_mut(&mut self) -> (&mut [[T; N]], &mut [T]); const fn as_rchunks_mut(&mut self) -> (&mut [T], &mut [[T; N]]); const unsafe fn as_chunks_unchecked_mut(&mut self) -> &mut [[T; N]]; }

(FCP's not done quite yet, but will in another day if I'm counting right.) FCP Complete: #74985 (comment)

MortenLohne, jasper310899, Aloso, n-gude, and Robbepop reacted with thumbs up emoji fee1-dead, jdahlstrom, robertknight, scottlamb, sk1p, and robinhundt reacted with hooray emoji joseluis, edwloef, and tuguzT reacted with eyes emoji

@scottmcm scottmcm added the S-blocked

Status: Blocked on something else such as an RFC or other implementation work.

label

Apr 11, 2025

@rustbot

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-libs

Relevant to the library team, which will review and decide on the PR/issue.

labels

Apr 11, 2025

@rust-log-analyzer

This comment has been minimized.

@scottmcm

@scottmcm scottmcm marked this pull request as ready for review

April 13, 2025 07:30

@rustbot

The Miri subtree was changed

cc @rust-lang/miri

@scottmcm scottmcm removed the S-blocked

Status: Blocked on something else such as an RFC or other implementation work.

label

Apr 13, 2025

@scottmcm

@rust-lang/libs-api I wanted to drop you a ping because there has been a reasonable amount of discussion during the FCP, so if you want me to hold off this for a bit to give you discussion time, let me know.

(I haven't seen any indication from comments that you've changed your minds, but it might just not have made it into the thread.)

@BurntSushi

Aye yeah, I'm still good with this. But given the discussion, holding for a second from another libs-api member seems prudent.

@dtolnay

LGTM as well. Thank you. We have talked about this feature across at least a half dozen library API team meetings and not diverged from favoring this design.

dtolnay

/// Panics if `N` is zero. This check will most probably get changed to a compile time
/// error before this method gets stabilized.
///
/// # Examples

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the section above (which I cannot comment because it is too far from the diff) we need to strike "This check will most probably get changed to a compile time error before this method gets stabilized."

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, that had even been mentioned in #74985 (comment) and I forgot.

Did a pass over the docs to fix that bit, elaborate on the resulting lengths, and also add a cross-references between these methods and as_flattened(_mut).

@rustbot ready

@dtolnay dtolnay added S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

and removed S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

labels

Apr 13, 2025

@scottmcm

Also mention them from as_flattened(_mut).

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

and removed S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Apr 19, 2025

@scottmcm

dtolnay

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@dtolnay

@bors

📌 Commit c49ddc0 has been approved by dtolnay

It is now in the queue for this repository.

@bors bors added the S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

label

Apr 28, 2025

ChrisDenton added a commit to ChrisDenton/rust that referenced this pull request

Apr 28, 2025

@ChrisDenton

…, r=dtolnay

Stabilize slice_as_chunks library feature

Draft as this needs rust-lang#139163 to land first.

FCP: rust-lang#74985 (comment)

Methods being stabilized are:

impl [T] {
    const fn as_chunks<const N: usize>(&self) -> (&[[T; N]], &[T]);
    const fn as_rchunks<const N: usize>(&self) -> (&[T], &[[T; N]]);
    const unsafe fn as_chunks_unchecked<const N: usize>(&self) -> &[[T; N]];
    const fn as_chunks_mut<const N: usize>(&mut self) -> (&mut [[T; N]], &mut [T]);
    const fn as_rchunks_mut<const N: usize>(&mut self) -> (&mut [T], &mut [[T; N]]);
    const unsafe fn as_chunks_unchecked_mut<const N: usize>(&mut self) -> &mut [[T; N]];
}

(FCP's not done quite yet, but will in another day if I'm counting right.) FCP Complete: rust-lang#74985 (comment)

bors added a commit to rust-lang-ci/rust that referenced this pull request

Apr 28, 2025

@bors

…enton

Rollup of 10 pull requests

Successful merges:

Failed merges:

r? @ghost @rustbot modify labels: rollup

bors added a commit to rust-lang-ci/rust that referenced this pull request

Apr 29, 2025

@bors

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Apr 29, 2025

@rust-timer

Rollup merge of rust-lang#139656 - scottmcm:stabilize-slice-as-chunks, r=dtolnay

Stabilize slice_as_chunks library feature

Draft as this needs rust-lang#139163 to land first.

FCP: rust-lang#74985 (comment)

Methods being stabilized are:

impl [T] {
    const fn as_chunks<const N: usize>(&self) -> (&[[T; N]], &[T]);
    const fn as_rchunks<const N: usize>(&self) -> (&[T], &[[T; N]]);
    const unsafe fn as_chunks_unchecked<const N: usize>(&self) -> &[[T; N]];
    const fn as_chunks_mut<const N: usize>(&mut self) -> (&mut [[T; N]], &mut [T]);
    const fn as_rchunks_mut<const N: usize>(&mut self) -> (&mut [T], &mut [[T; N]]);
    const unsafe fn as_chunks_unchecked_mut<const N: usize>(&mut self) -> &mut [[T; N]];
}

(FCP's not done quite yet, but will in another day if I'm counting right.) FCP Complete: rust-lang#74985 (comment)

@scottmcm scottmcm deleted the stabilize-slice-as-chunks branch

April 29, 2025 06:14

github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request

May 9, 2025

@ChrisDenton

…, r=dtolnay

Stabilize slice_as_chunks library feature

Draft as this needs rust-lang#139163 to land first.

FCP: rust-lang#74985 (comment)

Methods being stabilized are:

impl [T] {
    const fn as_chunks<const N: usize>(&self) -> (&[[T; N]], &[T]);
    const fn as_rchunks<const N: usize>(&self) -> (&[T], &[[T; N]]);
    const unsafe fn as_chunks_unchecked<const N: usize>(&self) -> &[[T; N]];
    const fn as_chunks_mut<const N: usize>(&mut self) -> (&mut [[T; N]], &mut [T]);
    const fn as_rchunks_mut<const N: usize>(&mut self) -> (&mut [T], &mut [[T; N]]);
    const unsafe fn as_chunks_unchecked_mut<const N: usize>(&mut self) -> &mut [[T; N]];
}

(FCP's not done quite yet, but will in another day if I'm counting right.) FCP Complete: rust-lang#74985 (comment)

compiler-errors added a commit to compiler-errors/rust that referenced this pull request

Jun 27, 2025

@compiler-errors

Fix 1.88 relnotes

r? @cuviper

rust-timer added a commit that referenced this pull request

Jun 27, 2025

@rust-timer

Rollup merge of #143059 - jieyouxu:slice-as-chunks, r=cuviper

Fix 1.88 relnotes

r? @cuviper

Labels

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

T-libs

Relevant to the library team, which will review and decide on the PR/issue.