Uh oh!
There was an error while loading. Please reload this page.
Add custom nth_back to Skip - #60454
Conversation
rust-highfive
commented
May 1, 2019
r? @cramertj (rust_highfive has picked a reviewer for you, use r? to override) |
cramertj
commented
May 1, 2019
r? @scottmcm |
timvermeulen
commented
May 2, 2019
Looks correct to me, though I don't think we want |
a516851 to
1edecacCompareacrrd
commented
May 2, 2019
Didn't notice that, I changed it |
scottmcm
commented
May 9, 2019
Look good, thanks! @bors r+ rollup |
bors
commented
May 9, 2019
📌 Commit 1edecacf2021a3381f447c949e6dc3018f4b0be4 has been approved by |
bors
commented
May 9, 2019
⌛ Testing commit 1edecacf2021a3381f447c949e6dc3018f4b0be4 with merge 8e9bb42c1edf098a01f7a18737f23ad257978854... |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
kennytm
commented
May 9, 2019
@bors r- retry |
acrrd
commented
May 9, 2019
timvermeulen
commented
May 20, 2019
Isn't this still a concern with the current implementation? |
b7fe202 to
edd4879Compareacrrd
commented
May 27, 2019
@timvermeulen thanks :) |
There was a problem hiding this comment.
In case n >= self.len() && self.len() != 0, additionally you need to do self.iter.nth_back(self.len() - 1); (or whatever that takes self.len()-items from the back) since the underlying iterator could have side effects.
letmut v = vec![];letmut it = [1,2,3,4,5].iter().cloned().inspect(|x| v.push(*x)).skip(1);assert_eq!(it.len(),4);assert_eq!(it.nth_back(4),None);assert_eq!(v, vec![5,4,3,2]);There was a problem hiding this comment.
Why let _ = and not just the call to nth_back?
There was a problem hiding this comment.
It was just for expressing intent to throw away the return value of nth_back, and I don't meant it is actually needed.
There was a problem hiding this comment.
I don't think the comment above was addressed; if disagree please add a test that demonstrates that the underlying iterator is still advanced.
(You could do that with inspect, or something like let mut it = ...; it.by_ref().skip(10).nth_back(100); assert_eq!(it.next_back(), ...);)
There was a problem hiding this comment.
Ok, I didn't understand you meant that.
There was a problem hiding this comment.
You're now calling self.len() three times, maybe it's better to store it in a variable first.
8e83410 to
2966f58Comparejonas-schievink
commented
Jun 18, 2019
Ping from triage, @acrrd what's the status of this? Are there still open review comments to be addressed, or is this waiting on someone to approve? |
acrrd
commented
Jun 19, 2019
@jonas-schievink I think all comments are addressed, waiting for approval. |
scottmcm
commented
Jun 20, 2019
Sorry for the delay re-reviewing, this looks great now! @bors r+ rollup |
bors
commented
Jun 20, 2019
📌 Commit e80a375 has been approved by |
Add custom nth_back to Skip Implementation of nth_back for Skip. Part of rust-lang#54054
Implementation of nth_back for Skip.
Part of #54054