rust-lang / rust-lang/rust-clippy

New lint for all/any after mapping to bool.

Open
#7,339 10 comments 0 reactions 1 assignee View on GitHub

@tamaroning is already working on this.

Since Feb 2, 2022.

A-lint E-medium
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

What it does

Eliminate map to bool if it is before a call to all/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
iter
    .map(|value| value > 0)
    .all(|x| x)

Could be written as:

iter.all(|value| value > 0)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.