rust/tests/ui/manual_strip_fixable.fixed
Samuel Tardieu 01d7a324dc manual_strip: use existing identifier instead of placeholder
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.
2025-02-15 16:03:11 +01:00

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);
}
}