'str::contains fails with "expected an Fn<(char,)> closure, found Cow<'_, str>" [duplicate]

I'm trying to check if name contains file_name or if file_name contains name (playground):

use regex::Regex;

fn main() {
    let slashes = Regex::new(r"[\\\/]").unwrap();
    let name = String::from("firstname");
    let file_name = String::from("secondst/ring");
    let replaced_name = slashes.replace_all(&file_name, "_");
    if name.contains(&replaced_name) || replaced_name.contains(&name) {
        //TODO
    }
}

I get:

error[E0277]: expected a `Fn<(char,)>` closure, found `Cow<'_, str>`
   --> src/main.rs:8:22
    |
8   |     if name.contains(&replaced_name) || replaced_name.contains(&name) {
    |             -------- ^^^^^^^^^^^^^^ expected an `Fn<(char,)>` closure, found `Cow<'_, str>`
    |             |
    |             required by a bound introduced by this call
    |
    = help: the trait `Fn<(char,)>` is not implemented for `Cow<'_, str>`
    = note: required because of the requirements on the impl of `FnOnce<(char,)>` for `&Cow<'_, str>`
    = note: required because of the requirements on the impl of `Pattern<'_>` for `&Cow<'_, str>`
note: required by a bound in `core::str::<impl str>::contains`

I tried the following variants with no success:

if name.contains(file_name) || file_name.contains(name) {
if name.contains(&file_name) || file_name.contains(&name) {
if name.to_string().contains(&file_name) || file_name.to_string().contains(&name) {


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source