In Rust, inner functions don't automatically have access to outer-scope variables. However, we can create closures using the || {}
syntax, which will have access to outer-scope variables.
fn main() {
let s = "hello";
let c = || {
println!("{}", s);
};
c(); // hello
}