From 9f106217c7598d0ec7b39e936d88f843a5d5175f Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 8 Jul 2021 21:53:06 +0200 Subject: [PATCH] Clarify closure capture modes slightly --- src/types/closure.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/types/closure.md b/src/types/closure.md index dfdd4ea57..7cfb3b059 100644 --- a/src/types/closure.md +++ b/src/types/closure.md @@ -49,10 +49,10 @@ f(Closure{s: s, t: &t}); The compiler prefers to capture a closed-over variable by immutable borrow, followed by unique immutable borrow (see below), by mutable borrow, and finally -by move. It will pick the first choice of these that allows the closure to -compile. The choice is made only with regards to the contents of the closure -expression; the compiler does not take into account surrounding code, such as -the lifetimes of involved variables. +by move. It will pick the first choice of these that is compatible with how the +captured variable is used inside the closure body. The compiler does not take +surrounding code into account, such as the lifetimes of involved variables, or +of the closure itself. If the `move` keyword is used, then all captures are by move or, for `Copy` types, by copy, regardless of whether a borrow would work. The `move` keyword is