> For the complete Mojo documentation index, see [llms.txt](/llms.txt).
> Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

# @__copy_capture

You can add the `__copy_capture` decorator on a parametric closure to capture
register-passable values by copy. This decorator causes a nested function to
copy the value of the indicated variable into the closure object at the point
of formation instead of capturing that variable by reference. This allows the
closure to be passed as an escaping function, without lifetime concerns.

```mojo
  def foo(x: Int):
      var z = x

      @__copy_capture(z)
      @parameter
      def formatter() -> Int:
          return z
      z = 2
      print(formatter())

  def main():
      foo(5)
```
