Closed
Description
What it does
prevents str_literal.chars().any(|x| x == c)
.
Lint Name
str_literal_chars_any
Category
restriction
Advantage
- Contributes optimizer: see https://godbolt.org/z/nsdPj3EaP, about x40 speed
Drawbacks
No response
Example
let foo: bool = "\\.+*?()|[]{}^$#&-~".chars().any(|x| x == c)
Could be written as:
let foo: bool = match c {
'\\' | '.' | '+' | '*' | '?' | '(' | ')' | '|' | '[' | ']' | '{'
| '}' | '^' | '$' | '#' | '&' | '-' | '~' => true,
_ => false,
}