-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
unnecessary_fold: .any and .all may not always be safe replacements of .fold #3351
Comments
I just ran into this. I think the short-circuiting methods ( At a minimum, the warning message should have a note like "this may change semantics" or "this may change side-effects". |
I suppose it may be possible to detect cases where there are side-effects? |
Hi, I also ran into this. Clippy suggests replacing |
Also just noticed this. I think it's good to mention |
Clippy version: 0.0.212
https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#unnecessary_fold
Both .any and .all are short-circuiting while .fold evaluates every element in the iterator, if the iterator incurs side effects these two methods will have different behavior than .fold.
For example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=893a485dc791c89d95d6ce6f744af9bf
The text was updated successfully, but these errors were encountered: