Rust

Rust

Made by DeepSource

Found collapsible .replace(..) method calls RS-P1007

Performance
Minor

Multiple consecutive replace(..) calls with the same replacement text can result in poor performance. Oftentimes, these replace calls can be merged.

Consider using .replace(|c| matches!(c, <ch> | <ch>), <replacement>).

Bad practice

"this is a string"
    .replace('i', "z")
    .replace('t', "z")

Recommended

"this is a string"
    .replace(|c| matches!(c, 'i' | 't'), "z")