-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add slice take methods #88502
Add slice take methods #88502
Conversation
As far as I can tell, LukasKalbertodt is no longer a member of the rust team, and that confused the automation. Assigning to a random libs-api member. r? @dtolnay |
☔ The latest upstream changes (presumably #88618) made this pull request unmergeable. Please resolve the merge conflicts. |
ping from triage: @rustbot label: +S-waiting-on-author -S-waiting-on-review |
6febdb7
to
9120bc4
Compare
This comment has been minimized.
This comment has been minimized.
9120bc4
to
6d8f23e
Compare
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #89158) made this pull request unmergeable. Please resolve the merge conflicts. |
@ibraheemdev Ping from triage, CI is still red here. |
0c68175
to
3d54e0f
Compare
I want to mention that it's actually a fourth take on this feature. Previous attempts (chronological order, first to last): |
☔ The latest upstream changes (presumably #88540) made this pull request unmergeable. Please resolve the merge conflicts. |
3d54e0f
to
8db85a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, this looks good. It's hard for me to judge how well these &mut &'a Self
signatures are going to work in practice, but I am excited for people to try it.
@bors r+ |
📌 Commit 8db85a3 has been approved by |
(Unbounded, Included(i)) => (Direction::Front, i.checked_add(1)?), | ||
(Excluded(i), Unbounded) => (Direction::Back, i.checked_add(1)?), | ||
(Included(i), Unbounded) => (Direction::Back, *i), | ||
_ => unreachable!(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really like the presence of panic call here which optimiser will have to remove. Would it make more sense to make this a method of OneSidedRange
in order to statically eliminate impossible cases?
…askrgr Rollup of 5 pull requests Successful merges: - rust-lang#88502 (Add slice take methods) - rust-lang#91313 (expand: Turn `ast::Crate` into a first class expansion target) - rust-lang#91424 (Update LLVM with patches for better llvm-cov diagnostics) - rust-lang#91425 (Include lint errors in error count for `-Ztreat-err-as-bug`) - rust-lang#91430 (Add tests for `normalize-docs` overflow errors) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
slice: &[(); usize::MAX], method: take, | ||
(take_in_bounds_max_range_to, (..usize::MAX), Some(EMPTY_MAX), &[(); 0]), | ||
(take_oob_max_range_to_inclusive, (..=usize::MAX), None, EMPTY_MAX), | ||
(take_in_bounds_max_range_from, (usize::MAX..), Some(&[] as _), EMPTY_MAX), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test fails in Miri, and I am trying to find out why... help would be appreciated. Here's the Zulip thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, turns out that even with rustc
this test diverges in debug mode, since it starts a loop of size usize::MAX
. Miri doesn't optimize so it has no way to run this test.
Revival of #62282
This PR adds the following slice methods:
take
take_mut
take_first
take_first_mut
take_last
take_last_mut
r? @LukasKalbertodt