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
What it does
Rust 1.100.0 will stabilize the
str::trim_prefix()andtrim_suffix()methods. The previous workaround for them wass.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
Could be written as:
Comparison with existing lints
No response
Additional Context
No response