Understanding Closures in Rust.
Published in
6 min readJun 25, 2019
Summary
- Closures are a combination of a function pointer (
fn
) and a context. - A closure with no context is just a function pointer.
- A closure which has an immutable context belongs to
Fn
. - A closure which has a mutable context belongs to
FnMut
. - A closure that owns its context belongs to
FnOnce
.