Skip to content
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

Merged
merged 1 commit into from
Feb 18, 2020

Conversation

ollie27
Copy link
Member

@ollie27 ollie27 commented Jan 28, 2020

The main improvement is to make last no longer recursive.

The main improvement is to make `last` no longer recursive.
@rust-highfive
Copy link
Collaborator

r? @withoutboats

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 28, 2020
if self.n > 0 {
// nth(n) skips n+1
if self.iter.nth(self.n - 1).is_none() {
return None;
Copy link
Member

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)?;

Copy link
Member Author

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.

@JohnCSimon JohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 16, 2020
@Dylan-DPC-zz
Copy link

r? @KodrAus

@Amanieu
Copy link
Member

Amanieu commented Feb 17, 2020

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Feb 17, 2020

📌 Commit 84f3356 has been approved by Amanieu

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 17, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Feb 17, 2020
Simplify `Skip::nth` and `Skip::last` implementations

The main improvement is to make `last` no longer recursive.
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Feb 18, 2020
Simplify `Skip::nth` and `Skip::last` implementations

The main improvement is to make `last` no longer recursive.
bors added a commit that referenced this pull request Feb 18, 2020
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
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Feb 18, 2020
Simplify `Skip::nth` and `Skip::last` implementations

The main improvement is to make `last` no longer recursive.
bors added a commit that referenced this pull request Feb 18, 2020
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
@bors bors merged commit 84f3356 into rust-lang:master Feb 18, 2020
@ollie27 ollie27 deleted the skip_nth_last branch February 18, 2020 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants