-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Fix doc test for Vec::retain(), now passes clippy::eval_order_dependence #81811
Conversation
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
@bors r+ rollup |
📌 Commit d9d1d3a90992ad0e503b556fad515cd42f87dfbe has been approved by |
That example is supposed to illustrate:
Now that you removed the index it doesn't make much sense anymore. |
I see what you mean. I'm not 100% sure what that comment is saying exactly, but maybe changing "index" to "iterator" would be enough to make it right? |
5c4c279
to
490bcbe
Compare
Turns out, neither did I. The comment is saying that the result of the It is NOT talking - as I had misunderstood initially - about the specific binding You could leave the comment unchanged as it is technically correct after all. Maybe something like |
After thinking about it a bit I think the main point is that in the first example the decision is made purely based on the element itself, while in the second it is made based on the external state (the array). With that in mind, I reworked the comment as follows:
|
490bcbe
to
91fb1a2
Compare
Sounds good 👍 |
Great! Thanks very much for your input. |
Hm, didn't notice at first but you replaced
|
Can you point me to somewhere I can read more about the exact order property? I've googled it but it just points back to this same comment. It doesn't mean anything special to me. |
It refers to the first part of the
So for:
which results in If the elements weren't visited in the original order,
giving you If it wouldn't visit elements exactly once it could even do
which would panic on the |
Yeah, ok, I guess it sounded a bit strange the way it's written as "exact order". I found the wording confusing originally, but I get the gist of it. I think I can clarify it though.
|
91fb1a2
to
0488afd
Compare
@m-ou-se There were some additional comments after your approval but think it's ready to re-approve now, could you please take a look? |
Hi @m-ou-se, are you able to re-approve? Is there some other process for getting this back into the queue? |
@bors r+ rollup |
📌 Commit 0488afd has been approved by |
Rollup of 8 pull requests Successful merges: - rust-lang#81811 (Fix doc test for Vec::retain(), now passes clippy::eval_order_dependence) - rust-lang#81900 (Organize trait test files) - rust-lang#81995 (Fix suggestion to introduce explicit lifetime) - rust-lang#82031 (Drop an unnecessary intermediate variable) - rust-lang#82033 (Refactor `get_word_attr` to return only `Option`) - rust-lang#82040 (Add test to prevent src link regression) - rust-lang#82041 (Add docs for shared_from_slice From impls) - rust-lang#82050 (Added tests to drain an empty vec) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
The examples added in rust-lang#60396 used a "clever" post-increment hack, unrelated to the actual point of the examples. That hack was found [confusing] in the users forum, and rust-lang#81811 already changed the `Vec` example to use a more direct iterator. This commit changes `String` and `VecDeque` in the same way for consistency. [confusing]: https://users.rust-lang.org/t/help-understand-strange-expression/62858
…lett Update the examples in `String` and `VecDeque::retain` The examples added in rust-lang#60396 used a "clever" post-increment hack, unrelated to the actual point of the examples. That hack was found [confusing] in the users forum, and rust-lang#81811 already changed the `Vec` example to use a more direct iterator. This commit changes `String` and `VecDeque` in the same way for consistency. [confusing]: https://users.rust-lang.org/t/help-understand-strange-expression/62858
Doc test for Vec::retain() works correctly but is flagged by clippy::eval_order_dependence. Fix avoids the issue by using an iterator instead of an index.