Skip to content

unnecessary_fold: .any and .all may not always be safe replacements of .fold #3351

Open
@ghost

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingL-suggestionLint: Improving, adding or fixing lint suggestions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions