Rust: Closures
Status: Courses
-
Closures are functions but with env and scope.
-
They do not have names assigned to them.
-
Closures use the syntax
| | { }- where
| |holds the arguments being passed { }holds the code
- where
-
For Example
#![allow(unused)] fn main() { // Definition of the Closure let adder = |a, b| { a + b; }; // Usage of the closure let five_plus_two = adder(5,2); }