Conceptual
Login

Closures and Variable Capture

A closure captures the variables it uses from the enclosing scope, either by reference or by taking ownership, which determines whether the environment must outlive the closure. Capture mode decides whether a closure can escape its creating scope or cross a thread boundary.

Questions this Concept answers

  • Why does a closure that merely borrows its captures sometimes fail to compile when handed to kernel code?