-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Correct extract_if
sample equivalent.
#135734
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @the8472 (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
Checking in on this. It would be nice if this could be fixed before |
Thanks for the PR! Agreed that this should be updated, but I think it could be simplified a bit and we should be able to do a better assertion. |
This comment has been minimized.
This comment has been minimized.
eb21a91
to
6a99ade
Compare
3fc83d2
to
215ab80
Compare
I've rebased and implemented the requested change. |
Ooook, I think this is done now. Thanks for your guidance! |
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.
Looks great! Please squash then should be good
Simpler predicate. Compare sample code output to that of the library function.
fc42309
to
52d806a
Compare
🟩 Hulk Squash! 🟩 |
Rollup of 4 pull requests Successful merges: - rust-lang#135734 (Correct `extract_if` sample equivalent.) - rust-lang#140307 (Refactor rustc_on_unimplemented's filter parser) - rust-lang#140644 (Revert "Avoid unused clones in Cloned<I> and Copied<I>") - rust-lang#140648 (Update `compiler-builtins` to 0.1.157) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#135734 - nk9:extract_if-doc-equivalent, r=tgross35 Correct `extract_if` sample equivalent. Tracking issue: rust-lang#43244 Original PR: rust-lang#133265 The sample code marked as equivalent in the doc comment isn't currently equivalent. Given the same predicate and range, if your vector were `[1, 2, 3, 3, 3, 3, 3, 3, 4, 5, 6]`, then all of the 3s would be removed. `i` is only incremented when an element is dropped, but `range.end` is unchanged, so the items shift down. I got very confused when reading the docs and trying to square this sample code with the explanation of how the function works. Fortunately, the real `extract_if()` does not have this problem. I've added an `end` variable to align the behavior. I've also taken the opportunity to simplify the predicate, which now just matches odd numbers, and to pad out the vec of numbers to line up the zero-indexed range with the integers in the vec. r? the8472
…gross35 Correct `extract_if` sample equivalent. Tracking issue: rust-lang#43244 Original PR: rust-lang#133265 The sample code marked as equivalent in the doc comment isn't currently equivalent. Given the same predicate and range, if your vector were `[1, 2, 3, 3, 3, 3, 3, 3, 4, 5, 6]`, then all of the 3s would be removed. `i` is only incremented when an element is dropped, but `range.end` is unchanged, so the items shift down. I got very confused when reading the docs and trying to square this sample code with the explanation of how the function works. Fortunately, the real `extract_if()` does not have this problem. I've added an `end` variable to align the behavior. I've also taken the opportunity to simplify the predicate, which now just matches odd numbers, and to pad out the vec of numbers to line up the zero-indexed range with the integers in the vec. r? the8472
Rollup of 4 pull requests Successful merges: - rust-lang#135734 (Correct `extract_if` sample equivalent.) - rust-lang#140307 (Refactor rustc_on_unimplemented's filter parser) - rust-lang#140644 (Revert "Avoid unused clones in Cloned<I> and Copied<I>") - rust-lang#140648 (Update `compiler-builtins` to 0.1.157) r? `@ghost` `@rustbot` modify labels: rollup
Tracking issue: #43244
Original PR: #133265
The sample code marked as equivalent in the doc comment isn't currently equivalent. Given the same predicate and range, if your vector were
[1, 2, 3, 3, 3, 3, 3, 3, 4, 5, 6]
, then all of the 3s would be removed.i
is only incremented when an element is dropped, butrange.end
is unchanged, so the items shift down. I got very confused when reading the docs and trying to square this sample code with the explanation of how the function works.Fortunately, the real
extract_if()
does not have this problem. I've added anend
variable to align the behavior. I've also taken the opportunity to simplify the predicate, which now just matches odd numbers, and to pad out the vec of numbers to line up the zero-indexed range with the integers in the vec.r? the8472