The error occurs because you are trying to move a value out of a reference, which is forbidden in Rust. To fix this, change the function parameter to take ownership of the value instead of borrowing it, or clone the value 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 here
}
If you must keep the original value, clone it before passing it:
fn main() {
let s = String::from("hello");
takes_ownership(s.clone()); // s is cloned, original remains valid
}