-
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
Tracking issue for Vec::remove_item #40062
Comments
PR moved to #40325 due to reasons |
Comments from original thread:
|
@clarcharr for |
@madseagames I meant specifically a method that searches for the item from the end of the vec instead of the beginning |
What do you think about adding |
I like |
It would be nice if this was more generic. we really want the remove_item "item: &T" to be "something that we can compare equality with the type in the container". This would let remove_item() walk the T items, compare equality, and remove if equal. |
Seems reasonable to change the signature to |
Reviewing the naming used in method names and the docs, it would seem that iterators yield items while vecs contain elements. Considering that we insert elements then we should also remove elements and the method should be called fn remove_by<F: FnMut(&T) -> bool>(&mut self, f: F) |
Any plan to stabilize this? |
This has been in nightly for a year with no issue reported on the method itself. There are proposals for additional methods, but that shouldn’t block this one. Please submit separate PRs or RFCs. @rfcbot fcp merge |
Team member @SimonSapin has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
Are we switching to a |
Oops, sorry I missed that. Yes, let’s. |
Again here, as a maintainer of collections that offer the Vec and VecDeque APIs I'd like at least a summary comment explaining what this method does, why this design was followed, alternatives, and addressing the issues mentioned here that have received zero replies:
|
Not an issue with the method per se, but it may need to be very clearly documented that the reference is not supposed to be to an item that is in the Users coming from the C world of pointers but no proper equality comparison, may be confused by this method, e.g. https://users.rust-lang.org/t/difficult-borrowing-situation/16794 The |
@SimonSapin as the proposer for FCP, do you have thoughts on @gnzlbg's concern? |
My thinking is that the |
cc @SimonSapin re. #40062 (comment) |
I don’t have a strong desire for this particular feature myself, I proposed FCP as an effort to reduce the number of features in "unstable limbo". That said: Regarding
|
I notice two things:
I think we should not stabilize this just because it exists, but instead someone should come up with a well justified explanation of exactly what the best "find and remove" set of methods of vec-likes would be. |
Good points.
|
@rfcbot resolve rationale-and-vecdeque I don't want to personally be on the hook for blocking this any more |
Checking KodrAus’ checkbox per rust-lang/team@45013d1 |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period, with a disposition to close, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. |
…e-item, r=Mark-Simulacrum Deprecate `Vec::remove_item` In rust-lang#40062 we decided to remove that method. In rust-lang#71834 it was said that we want to deprecate it for a few cycles before removing it. That's what this PR does.
Since we've merged the deprecation would we like to close this tracking issue now? Or keep it open until the unstable deprecated method is removed entirely? |
I think keeping this open until we removed the method is a good idea. How long do we want to wait with that by the way? I guess a couple of cycles is sufficient? |
Before closing, it would be great if someone could suggest a "one clean and obvious" way to remove the first/last occurance of an item from a Vector. Irrespective of the arguments made here, a method removing the first/last occurance of an item is provided across all major programming languages, and is to be "expected" Anyone new to rust is bound to google "remove from vec rust" and end up on this discussion which would only leave them more confused. |
This StackOverflow Q&A should answer those questions. But here is a copy of my answer for convenience: Remove first element equal to
|
It might be worth adding more examples (maybe all of the ones above) to the |
I'd like to add those to the docs, should they go along the example that we currently have? |
@nrabulinski What examples are you referring to? I could imagine those "remove examples" either going on the type (as a new section "Removing elements" or something like that) or directly on the |
Thank you. I was referring to those "remove examples" as to whether I should append them to what we currently have in docs for |
That sounds fine to me. Feel free to just open a PR and we can still see about the specifics then :) |
…gisa Remove unstable deprecated Vec::remove_item Closes rust-lang#40062 The `Vec::remove_item` method was deprecated in `1.46.0` (in August of 2020). This PR now removes that unstable method entirely.
…gisa Remove unstable deprecated Vec::remove_item Closes rust-lang#40062 The `Vec::remove_item` method was deprecated in `1.46.0` (in August of 2020). This PR now removes that unstable method entirely.
…gisa Remove unstable deprecated Vec::remove_item Closes rust-lang#40062 The `Vec::remove_item` method was deprecated in `1.46.0` (in August of 2020). This PR now removes that unstable method entirely.
…gisa Remove unstable deprecated Vec::remove_item Closes rust-lang#40062 The `Vec::remove_item` method was deprecated in `1.46.0` (in August of 2020). This PR now removes that unstable method entirely.
Implemented in #40325
The text was updated successfully, but these errors were encountered: