Implement VecDeque::extract_if by tisonkun · Pull Request #147780 · 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

Conversation31 Commits1 Checks11 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 }})

@tisonkun

@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

Oct 16, 2025

@rustbot

r? @joboet

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

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@tisonkun

This is now ready for review. I'm trying to port some tests from LinkedList's extract_if cases.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

paolobarbolini

// We use copy for move, and never touch this element again.
unsafe {
let hole_slot = self.vec.ptr().add(idx - self.del);
ptr::copy_nonoverlapping(cur, hole_slot, 1);

Choose a reason for hiding this comment

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

Should this instead be wrap_copy?

Choose a reason for hiding this comment

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

Yes correct. Try fix in a7d0a43.

Choose a reason for hiding this comment

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

CI looks happy. I'm not sure how to ensure the manner, i.e., constructing a VecDeque that wrap the underlying vec.

joboet

@joboet joboet left a comment • Loading

Choose a reason for hiding this comment

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

I think the algorithm here could be improved – e.g. it's not always necessary to backshift the remaining items, as one can just modify the head – but that's out of scope for this PR.

Some small nits, this looks fine otherwise.

View changes since this review

@joboet joboet 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

Oct 20, 2025

@tisonkun

@joboet Thanks for your review! I'd integrate the comments later and ping you when it's ready for another review.

@tisonkun

@joboet All comments address.

I found VecDeque::rotate_left that can easily make a non-contiguous deque and the private VecDeque::is_contiguous for testing assertions.

The current test case is trivial non-contiguous. If you have other edge cases in mind, please describe them so I can add them.

@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

Oct 27, 2025

@joboet

@bors

✌️ @tisonkun, you can now approve this pull request!

If @joboet told you to "r=me" after making some further change, please make that change, then do @bors r=@joboet

@tisonkun

@joboet would you suggest squash all commits into one, or in logical several, e.g. impl+test?

I'd prefer one, and IIRC GitHub's squash and merge would do as this, not sure how rustbot would do.

@joboet

One is fine, but as you choose. Eight is a little too many though, there's no need to preserve every little step.

@tisonkun

Signed-off-by: tison wander4096@gmail.com

@rustbot

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@joboet

@bors

📌 Commit 06a2e72 has been approved by joboet

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors

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

and removed S-waiting-on-review

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

labels

Oct 31, 2025

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

Oct 31, 2025

@matthiaskrgr

bors added a commit that referenced this pull request

Oct 31, 2025

@bors

Rollup of 7 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

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

Oct 31, 2025

@matthiaskrgr

bors added a commit that referenced this pull request

Oct 31, 2025

@bors

Rollup of 9 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

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

Nov 1, 2025

@Zalathar

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

Nov 1, 2025

@Zalathar

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

Nov 1, 2025

@Zalathar

bors added a commit that referenced this pull request

Nov 1, 2025

@bors

Rollup of 9 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

rust-timer added a commit that referenced this pull request

Nov 1, 2025

@rust-timer

Rollup merge of #147780 - tisonkun:vec-deque-extract-if, r=joboet

Implement VecDeque::extract_if

This refers to #147750.

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

Nov 30, 2025

@matthiaskrgr

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

Nov 30, 2025

@bors

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.