New lint: Suggest str::strip_*
over str::{starts,ends}_with
and slicing it
#5734
Labels
A-lint
Area: New lints
E-medium
Call for participation: Medium difficulty level problem and requires some initial experience.
L-complexity
Lint: Belongs in the complexity lint group
Categories: Performance, Correctness, complexity
Using
str::strip
removes the panic code inserted by slicing with pattern length.Also it removes the need for duplicating/storing pattern used by
str::{starts,ends}_with
and (str[len..]
orstr[..len]
).Which it may removes the typing mistakes (do not repeat yourself).
Auto-apply suggestion ability
What it does
Suggest using
strip_{prefix,suffix}
overstr::{starts,ends}_with
and slicing by pattern's length.Known problems
None.
Example
Could be written as:
The text was updated successfully, but these errors were encountered: