When the manually stripped entity receives a name as the first use through a simple `let` statement, this name can be used in the generated `if let Some(…)` expression instead of a placeholder.
15 lines
365 B
Rust
15 lines
365 B
Rust
#![warn(clippy::manual_strip)]
|
|
|
|
fn main() {
|
|
let s = "abc";
|
|
|
|
if let Some(stripped) = s.strip_prefix("ab") {
|
|
//~^ ERROR: stripping a prefix manually
|
|
println!("{stripped}{}", stripped);
|
|
}
|
|
|
|
if let Some(stripped) = s.strip_suffix("bc") {
|
|
//~^ ERROR: stripping a suffix manually
|
|
println!("{stripped}{}", stripped);
|
|
}
|
|
}
|