The move keyword forces a Rust closure to take ownership of captured variables instead of borrowing them.
The move keyword forces a closure to take ownership of all variables it captures from its environment, rather than borrowing them. This is required when passing closures to threads or when the captured data needs to outlive the scope where it was defined.
let s = String::from("hello");
let closure = move || println!("{s}");
// s is moved into the closure and cannot be used here
The move keyword tells Rust to copy the data a function uses into the function itself, rather than just letting it look at the original data. This is like handing someone a physical document to keep, instead of just letting them read it on your desk. You use it when you need the function to own the data permanently, such as when sending work to a separate thread.