The error E0382 occurs because the closure takes ownership of a variable, moving it out of scope before you can use it again. To fix this, change the closure to borrow the variable by adding a reference (&) to the captured value or use the move keyword if you intend to transfer ownership explicitly.
let data = String::from("hello");
let closure = || println!("{}", &data); // Borrow data instead of moving it
closure();
println!("{}", data); // data is still valid here
If you need the closure to own the data, use move and ensure you don't access the original variable afterward:
let data = String::from("hello");
let closure = move || println!("{}", data); // Takes ownership
closure();
// println!("{}", data); // Error: data was moved