A closure is an anonymous function that can capture variables from the scope where it's defined. They're the glue of iterator chains and the reason functional-style Rust reads so cleanly.
The syntax
A closure is |args| body: |x| x + 1 takes x and returns x + 1. Unlike a function, it can use variables from its surrounding scope without taking them as parameters — it captures them. The compiler infers the argument and return types from how you use it.
Three ways to capture
A closure captures each variable in the least-restrictive way it can: by immutable reference if it only reads, by mutable reference if it modifies, or by value if it must own. These three modes correspond to three traits — Fn (reads captures), FnMut (mutates captures), FnOnce (consumes captures, callable once). You rarely name them; the compiler picks, and functions that take closures declare which they accept.
Fn); mutating capture is a mutable borrow (FnMut); consuming capture is a move (FnOnce). The same aliasing logic from the Borrowing track decides which trait a closure implements.move closures
Prefix a closure with move to force it to take ownership of everything it captures: move |x| x + base. This is essential when the closure outlives the current scope — passing it to a thread, returning it, storing it. The Concurrency track relies on move closures to hand data safely to threads.