Fix E0382 by cloning the value before moving it or by passing a reference instead of the value itself. Use .clone() to create a copy if you need to use the original variable again after the move.
let s1 = String::from("hello");
let s2 = s1.clone(); // Creates a new copy
// s1 is still valid here
println!("{s1}");
println!("{s2}");
Alternatively, pass a reference to avoid moving ownership:
fn takes_ownership(some_string: &String) {
println!("{some_string}");
}
fn main() {
let s = String::from("hello");
takes_ownership(&s); // Pass a reference
println!("{s}"); // s is still valid
}