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

Purge map(|&x| x) et al #22243

Closed
Gankra opened this issue Feb 12, 2015 · 3 comments
Closed

Purge map(|&x| x) et al #22243

Gankra opened this issue Feb 12, 2015 · 3 comments
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@Gankra
Copy link
Contributor

Gankra commented Feb 12, 2015

Option and IteratorExt both have .cloned() which is sugar for this operation.

AKA

  • .map(|x| *x)
  • .map(|x| x.clone())
  • .map(|x| (*x).clone()) (yes, really)
@kmcallister kmcallister added C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Feb 13, 2015
ruuda added a commit to ruuda/rust that referenced this issue Feb 13, 2015
This resolves rust-lang#22243, at least for one-letter variable names.
@ruuda ruuda mentioned this issue Feb 13, 2015
steveklabnik pushed a commit to steveklabnik/rust that referenced this issue Feb 13, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Feb 13, 2015
This resolves rust-lang#22243 for the single-letter variables that I could grep. Some occurences could not be replaced.
steveklabnik added a commit to steveklabnik/rust that referenced this issue Feb 14, 2015
This resolves rust-lang#22243 for the single-letter variables that I could grep. Some occurences could not be replaced.
steveklabnik added a commit to steveklabnik/rust that referenced this issue Feb 15, 2015
This resolves rust-lang#22243 for the single-letter variables that I could grep. Some occurences could not be replaced.
@untitaker
Copy link
Contributor

There are two or three occurrences of code like this:

edible.iter().map(|x| TokenType::Token(x.clone()))

Should they also be replaced?

Also, src/doc/style/style/naming/containers.md contains the same code again.

@Gankra
Copy link
Contributor Author

Gankra commented Feb 22, 2015

It can be converted to edible.iter().cloned().map(TokenType::Token). Whether that is better is a matter of taste.

bombless pushed a commit to bombless/rust that referenced this issue Feb 23, 2015
@Gankra
Copy link
Contributor Author

Gankra commented Mar 4, 2015

Calling this sufficiently resolved.

@Gankra Gankra closed this as completed Mar 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants