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

name anonymous fn parameters in libcore traits #39705

Merged
merged 1 commit into from
Feb 10, 2017

Conversation

tspiteri
Copy link
Contributor

@tspiteri tspiteri commented Feb 9, 2017

This follows the discussion in rust-lang/rfcs#1685. The patch gives names to anonymous parameters in libcore traits. It would have two benefits I can think of: firstly it would provide names to tools that can use the names from the traits, and secondly core/std can serve as an example when writing traits; this change helps by not encouraging the use of anonymous parameters.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @aturon (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.

@@ -1178,8 +1178,8 @@ impl TwoWaySearcher {
trait TwoWayStrategy {
type Output;
fn use_early_reject() -> bool;
fn rejecting(usize, usize) -> Self::Output;
fn matching(usize, usize) -> Self::Output;
fn rejecting(a: usize, b: usize) -> Self::Output;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there are more descriptive names we could use here? I don't know enough about this piece of code, but @Kimundi might.

Copy link
Contributor Author

@tspiteri tspiteri Feb 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried not to be creative and used names already used by the implementations of the trait. I didn't give too much thought to this particular example as it is actually a private trait and does not appear in the docs like the others.

Edit: Looking further into this, the names a and b are what is actually used in the docs themselves. The variants listed in std::str::pattern::SearchStep talk about haystack[a..b].

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough -- thanks!

@aturon
Copy link
Member

aturon commented Feb 9, 2017

@bors: r+ rollup

@bors
Copy link
Contributor

bors commented Feb 9, 2017

📌 Commit e626a68 has been approved by aturon

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Feb 10, 2017
…uron

name anonymous fn parameters in libcore traits

This follows the discussion in rust-lang/rfcs#1685. The patch gives names to anonymous parameters in libcore traits. It would have two benefits I can think of: firstly it would provide names to tools that can use the names from the traits, and secondly core/std can serve as an example when writing traits; this change helps by not encouraging the use of anonymous parameters.
bors added a commit that referenced this pull request Feb 10, 2017
Rollup of 6 pull requests

- Successful merges: #39587, #39674, #39693, #39700, #39705, #39707
- Failed merges:
@bors bors merged commit e626a68 into rust-lang:master Feb 10, 2017
@tspiteri tspiteri deleted the name-trait-fn-params branch February 10, 2017 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants