Understanding Closures in Rust.

Andrew Pritchard
Jun 25, 2019 · 6 min read


  • 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.

Understanding the different types of closures in Rust.