Skip to content

slice: Mark rotate_left, rotate_right unstably const #143554

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 and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

okaneco
Copy link
Contributor

@okaneco okaneco commented Jul 7, 2025

  • Add the const unstable const_slice_rotate feature
  • Mark <[T]>::rotate_left and <[T]>::rotate_right as const unstable

The internal rotate functions use <*mut T>::replace and ptr::swap_nonoverlapping which were const-stabilized in 1.88.

Two changes were needed in the rotate.rs module to make these functions const:

  1. A usage of cmp::min was replaced with a local function implementation of Ord::min.
  2. A for start in 1..gcd loop was changed to a while loop with an increment variable.

This needs libs-api approval and cc-ing const-eval.
Tracking issue will be made upon acceptance.

@rustbot
Copy link
Collaborator

rustbot commented Jul 7, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
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 Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants