fn closure in RBE
This commit is contained in:
parent
9d4f5b661b
commit
aa83db6f7a
12
rustbyexample/fn.d/closures.rs
Normal file
12
rustbyexample/fn.d/closures.rs
Normal file
@ -0,0 +1,12 @@
|
||||
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());
|
||||
}
|
Loading…
Reference in New Issue
Block a user