-
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
Add LinkedList::remove() #68705
Add LinkedList::remove() #68705
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @kennytm (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
iter.next_back(); | ||
} | ||
iter.tail | ||
}; |
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.
Could this use the cursors API (currently unstable, but we can use it)? It looks like that should make this a bit cleaner.
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.
That seems reasonable. I'll push a commit with that in a bit.
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 have pushed up the changes
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
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.
Looking much better, left a few more comments though.
cursor.remove_current() | ||
} else { | ||
let mut cursor = self.cursor_back_mut(); | ||
for _ in 0..len - at - 1 { |
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.
Can we pull out len - at - 1
to e.g. "offset_from_end" or something like that?
I've made the requested changes |
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.
r=me with a tracking issue filed and added, as well as commits squashed; thanks! Sorry for the delay in review.
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.
Threw out some potential re-wordings that you should feel free to ignore :-) And asked some questions so I can learn more about rust and writing code for others :-)
r=me with the comments resolved or not, just let me know if you want to fix any of them in this PR (if not I personally think this is fine to land without fixing them too) |
LinkedList::remove() removes the element at the specified index and returns it. Signed-off-by: Bijan Tabatabai <bijan311@yahoo.com>
I made some of the changes that mlodato517 suggested. This PR should be good to go now |
@bors r+ rollup Thanks! |
📌 Commit c797ce7 has been approved by |
Add LinkedList::remove() LinkedList::remove() removes the element at the specified index and returns it. I added this because I think having a remove function would be useful to have, and similar functions are in other containers, like Vec and HashMap. I'm not sure if adding a feature like this requires an RFC or not, so I'm sorry if this PR is premature.
Rollup of 5 pull requests Successful merges: - #68705 (Add LinkedList::remove()) - #68945 (Stabilize Once::is_completed) - #68978 (Make integer exponentiation methods unstably const) - #69266 (Fix race condition when allocating source files in SourceMap) - #69287 (Clean up E0317 explanation) Failed merges: r? @ghost
LinkedList::remove() removes the element at the specified index and returns it.
I added this because I think having a remove function would be useful to have, and similar functions are in other containers, like Vec and HashMap.
I'm not sure if adding a feature like this requires an RFC or not, so I'm sorry if this PR is premature.