You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Without the `move` keyword, the closure expression [infers how it captures each variable from its environment](../types/closure.md#capture-modes), preferring to capture by shared reference, effectively borrowing all outer variables mentioned inside the closure's body.
39
39
40
40
r[expr.closure.capture-mut-ref]
41
-
If needed the compiler will infer that instead mutable references should be taken, or that the values should be moved or copied (depending on their type) from the environment.
41
+
If needed, the compiler will instead infer that mutable references should be taken, or that the values should be moved or copied (depending on their type) from the environment.
42
42
43
43
r[expr.closure.capture-move]
44
44
A closure can be forced to capture its environment by copying or moving values by prefixing it with the `move` keyword. This is often used to ensure that the closure's lifetime is `'static`.
0 commit comments