-
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
Overload Iterator::last()
for IntoIter
.
#76087
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
IntoIter::last()
for Vec
.Iterator::last()
for Vec
.
Iterator::last()
for Vec
.Iterator::last()
for IntoIter
.
This is unsound. The |
I changed the implementation a bit copying what |
This was attempted before in #57246 EDIT: looking at this closer the drop order should be the same so this should be fine. |
I am quite new to raw Rust but AFAIK, but shouldn't the Lines 2762 to 2781 in db534b3
I am not sure what this is for, tho Line 2777 in db534b3
|
Yeah, the |
☔ The latest upstream changes (presumably #70793) made this pull request unmergeable. Please resolve the merge conflicts. |
@hbina any updates on this? |
Simply use the fact that `IntoIter` stores the end pointer and we can perform pointer arithmetic.
Simply does what next() does except it goes straight to the end of the array. Woopsie
0307fd1
to
76d06f0
Compare
@Dylan-DPC I have rebased to latest and accepted the change requested by @pickfire |
As I mentioned in #76087 (comment) all |
Suggested by @pickfire. Signed-off-by: Hanif Bin Ariffin <[email protected]>
76d06f0
to
91984e7
Compare
Just testing for functionality can be done in |
r? @KodrAus |
Does this make any difference in performance or binary size? Both the previous and the proposed implementation end up iterating through all elements to Drop them. |
☔ The latest upstream changes (presumably #80530) made this pull request unmergeable. Please resolve the merge conflicts. |
Simply use the fact that
IntoIter
stores the end pointer and wecan perform pointer arithmetic.
NOTE: Where is the test for this?