Closures
Closures
Closures implement three types of traits from standard library
Fn -> Immutable borrowing of values from outer scope
FnMut -> Mutable borrow of values from outer scope
FnOnce -> Takes the ownership from the outer scope
move keyword is used to move the ownership of outer scope variables to inside of closure
//example
let closure = |var| {
.....
...// write logic
}
Last updated
Was this helpful?