Lint for replacing `x.strip_[prefix/suffix](...).unwrap_or(x)` with `x.trim_[prefix/suffix](...)`
What it does
Rust 1.100.0 will stabilize the str::trim_prefix() and trim_suffix() methods. The previous workaround for them was s.strip_[prefix/suffix](...).unwrap_or(s). I think we should have a lint for the new method.
Advantage
It's just simpler, and perhaps also faster.
Drawbacks
No response
Example
let s: &str;
s.strip_prefix("foo").unwrap_or(s)
Could be written as:
let s: &str;
s.trim_prefix("foo")
Comparison with existing lints
No response
Additional Context
No response
@rustbot label good first issue
That sounds like a good and simple methods lint to me. Needs MSRV-checking though, but that is not hard ;)
Error: Unknown labels: first, good, issue
Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip.
@rustbot label "good first issue"
@rustbot claim