Skip to content

restrict: str_literal.chars().any(|x| x == c) affects performance negatively #10389

Closed
@KisaragiEffective

Description

@KisaragiEffective

What it does

prevents str_literal.chars().any(|x| x == c).

Lint Name

str_literal_chars_any

Category

restriction

Advantage

Drawbacks

No response

Example

let foo: bool = "\\.+*?()|[]{}^$#&-~".chars().any(|x| x == c)

Could be written as:

let foo: bool = match c {
    '\\' | '.' | '+' | '*' | '?' | '(' | ')' | '|' | '[' | ']' | '{'
    | '}' | '^' | '$' | '#' | '&' | '-' | '~' => true,
    _ => false,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions