-
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
Simplify Skip::nth
and Skip::last
implementations
#68597
Conversation
The main improvement is to make `last` no longer recursive.
(rust_highfive has picked a reviewer for you, use r? to override) |
if self.n > 0 { | ||
// nth(n) skips n+1 | ||
if self.iter.nth(self.n - 1).is_none() { | ||
return None; |
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 like using Try
in cases like this, self.iter.nth(self.n - 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.
That would work in this case but would make the code less symmetric with the other methods of Skip
which is why I didn't use ?
here.
r? @KodrAus |
@bors r+ rollup |
📌 Commit 84f3356 has been approved by |
Simplify `Skip::nth` and `Skip::last` implementations The main improvement is to make `last` no longer recursive.
Simplify `Skip::nth` and `Skip::last` implementations The main improvement is to make `last` no longer recursive.
Rollup of 8 pull requests Successful merges: - #67272 (recursion_limit parsing handles overflows) - #68597 (Simplify `Skip::nth` and `Skip::last` implementations) - #68767 (macOS: avoid calling pthread_self() twice) - #69175 (Do not ICE when encountering `yield` inside `async` block) - #69223 (Ignore GDB versions with broken str printing.) - #69244 (configure: set LLVM flags with a value) - #69249 (Stabilize {f32, f64}::{LOG2_10, LOG10_2}) - #69252 (Clean out unused directories for extra disk space) Failed merges: r? @ghost
Simplify `Skip::nth` and `Skip::last` implementations The main improvement is to make `last` no longer recursive.
Rollup of 8 pull requests Successful merges: - #67272 (recursion_limit parsing handles overflows) - #68597 (Simplify `Skip::nth` and `Skip::last` implementations) - #68767 (macOS: avoid calling pthread_self() twice) - #69175 (Do not ICE when encountering `yield` inside `async` block) - #69223 (Ignore GDB versions with broken str printing.) - #69244 (configure: set LLVM flags with a value) - #69249 (Stabilize {f32, f64}::{LOG2_10, LOG10_2}) - #69252 (Clean out unused directories for extra disk space) Failed merges: r? @ghost
The main improvement is to make
last
no longer recursive.