The trait `FnMut` is not implemented for `String` when trying to split a string

All is in the documentation. You can provide one of:

  • A &str,
  • A char,
  • A closure,

Those three types implement the Pattern trait. You are giving a String to split instead of a &str.

Example:

fn main() {
    let x = "".to_string();
    let split = x.split("");
}

Leave a Comment