-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New lint for all/any after mapping to bool. #7339
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
Comments
In addition to The lint could be named Also this can be generalized further. Not just identity, but any closure where the input variable is referenced only one time in both iter.map(|x| foo(x)).flat_map(|x| bar(x))
// to
iter.flat_map(|x| bar(foo(x))) This can be called |
I think I'd like to give this a go. Safe to claim it? |
Absolutely! |
@rustbot claim |
Hard time finding time to work on this. Will still be trying to implement this but in the meantime anyone feel free to give this a shot. |
@rustbot unclaim |
@rustbot claim |
Hi, @camsteffen |
@tamaroning First get the ID of the closure parameter binding which is the |
@camsteffen |
What it does
Eliminate
map
tobool
if it is before a call toall
/any
Categories (optional)
What is the advantage of the recommended code over the original code
Shorter code.
Drawbacks
If the
map
operation has side-effect, applying the suggestion will change the meaning of the program.Example
Could be written as:
The text was updated successfully, but these errors were encountered: