Skip to content

needless_character_iteration false positive #12879

@aDotInTheVoid

Description

@aDotInTheVoid

This transformation isn't correct:

fn main() {
    let s = "Beyoncé";
    // EVERY character isn't ascii
    dbg!(s.chars().all(|c| !char::is_ascii(&c)));
    // ANY character isn't ascii
    dbg!(!s.is_ascii());
}
[src/main.rs:3:5] s.chars().all(|c| !char::is_ascii(&c)) = false
[src/main.rs:4:5] !s.is_ascii() = true

Originally posted by @aDotInTheVoid in #12815 (comment)

CC @GuillaumeGomez

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions