What Is the move Keyword for Closures in Rust?

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