Skip to content

Conversation

bjoernager
Copy link
Contributor

@bjoernager bjoernager commented Sep 21, 2025

Closes: #143812.

This PR stabilises the const_slice_rotate feature:

impl<T> [T] {
    pub const fn rotate_left(&mut self, mid: usize);

    pub const fn rotate_right(&mut self, k: usize);
}

No blockers or unresolved questions. FCP required.

Courtesy of @okaneco.

@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 Sep 21, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 21, 2025

r? @tgross35

rustbot has assigned @tgross35.
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

@bjoernager
Copy link
Contributor Author

bjoernager commented Sep 21, 2025

@rustbot label +T-libs-api -T-libs needs-fcp

r? libs-api

@rustbot rustbot added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 21, 2025
@rustbot rustbot assigned m-ou-se and unassigned tgross35 Sep 21, 2025
@rustbot rustbot added the needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. label Sep 21, 2025
@tgross35
Copy link
Contributor

We usually nominate for discussion rather than requesting a libs-api reviewer nowadays

r? libs
@rustbot label +I-libs-api-nominated

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Sep 22, 2025
@rustbot rustbot assigned Mark-Simulacrum and unassigned m-ou-se Sep 22, 2025
@rustbot rustbot added the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Sep 22, 2025
@GrigorenkoPV
Copy link
Contributor

Why do k and mid have different names? Is this intentional?

@bjoernager
Copy link
Contributor Author

bjoernager commented Sep 22, 2025

Why do k and mid have different names? Is this intentional?

I'm also confused by that. I would ask @frewsxcv as #46777 was the initial implementation of these methods (the previous rotate from #41670 only used mid).

The current naming convention suggests that both parameters be named offset.

@frewsxcv
Copy link
Contributor

I don't remember why I named them like that. Probably not intentional

@Amanieu Amanieu removed the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Sep 23, 2025
@Amanieu
Copy link
Member

Amanieu commented Sep 23, 2025

FCP started in #143812

@tgross35
Copy link
Contributor

I think it's fine to add a commit updating the argument names here, since that's effectively just a documentation change.

@scottmcm
Copy link
Member

scottmcm commented Sep 24, 2025

Why do k and mid have different names? Is this intentional?

It's because the one taking k is a k-rotation following the terminology of https://www.elementsofprogramming.com/eop_coloredlinks.pdf S10.4. And the other moves the element at mid to the front.

k-rotation rearrangement of a range [f, l) is equivalent to interchanging
the relative positions of the values in the subranges [f, m) and [m, l), where
m = f + ((l − f) − k) = l − k. m is a more useful input than k.

(At least IIRC that's why I wrote them this way -- note that the very earliest version of this was just rotate, without the left/right split.)


I would suggest not putting a parameter change in this PR, though. If this is just const-stabilizing, which should be uncontroversial, keep it to just that. Let any approval conversation about parameter names be in a different PR.

@Mark-Simulacrum Mark-Simulacrum changed the title Stabilise rotate_left and rotate_right in [_]. Stabilise rotate_left and rotate_right as const in [_]. Sep 28, 2025
@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-fcp Status: PR is in FCP and is awaiting for FCP to complete. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. labels Sep 28, 2025
@bjoernager bjoernager changed the title Stabilise rotate_left and rotate_right as const in [_]. Stabilise rotate_left and rotate_right in [_] as const fn items. Sep 30, 2025
@bjoernager bjoernager changed the title Stabilise rotate_left and rotate_right in [_] as const fn items. Stabilise rotate_left and rotate_right in [_] as const fn items. Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-fcp Status: PR is in FCP and is awaiting for FCP to complete. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tracking Issue for const_slice_rotate
9 participants