13 lines
340 B
Rust
13 lines
340 B
Rust
fn main() {
|
|
let outer_var = 42;
|
|
|
|
let closure_annotated = |i: i32| -> i32 { i + outer_var };
|
|
let closure_inferred = |i| i + outer_var;
|
|
|
|
println!("closure_annotated: {}", closure_annotated(1));
|
|
println!("closure_inferred: {}", closure_inferred(1));
|
|
|
|
let one = || 1;
|
|
println!("closure returning one: {}", one());
|
|
}
|