How to fix cannot move out of borrowed content

Fix the 'cannot move out of borrowed content' error by passing ownership directly or cloning the data instead of trying to move from a reference.

You cannot move out of borrowed content because the borrow checker prevents you from taking ownership of data you are only referencing. To fix this, change the function parameter to take ownership of the value instead of a reference, or clone the data if you need to keep the original.

fn takes_ownership(some_string: String) {
    println!("{some_string}");
}

fn main() {
    let s = String::from("hello");
    takes_ownership(s); // s is moved, not borrowed
}

If you must keep the original, clone it before passing it:

fn takes_ownership(some_string: String) {
    println!("{some_string}");
}

fn main() {
    let s = String::from("hello");
    takes_ownership(s.clone()); // s is cloned, original remains valid
}