Skip to content

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

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

Closed
KisaragiEffective opened this issue Feb 22, 2023 · 0 comments · Fixed by #11052
Closed
Labels
A-lint Area: New lints

Comments

@KisaragiEffective
Copy link
Contributor

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,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant